
obj/net/testinput:     file format elf32-i386


Disassembly of section .text:

00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
	// See if we were started with arguments on the stack
	cmpl $USTACKTOP, %esp
  800020:	81 fc 00 e0 bf ee    	cmp    $0xeebfe000,%esp
	jne args_exist
  800026:	75 04                	jne    80002c <args_exist>

	// If not, push dummy argc/argv arguments.
	// This happens when we are loaded by the kernel,
	// because the kernel does not know about passing arguments.
	pushl $0
  800028:	6a 00                	push   $0x0
	pushl $0
  80002a:	6a 00                	push   $0x0

0080002c <args_exist>:

args_exist:
	call libmain
  80002c:	e8 df 05 00 00       	call   800610 <libmain>
1:	jmp 1b
  800031:	eb fe                	jmp    800031 <args_exist+0x5>
	...

00800040 <umain>:
	}
}

void
umain(void)
{
  800040:	55                   	push   %ebp
  800041:	89 e5                	mov    %esp,%ebp
  800043:	57                   	push   %edi
  800044:	56                   	push   %esi
  800045:	53                   	push   %ebx
  800046:	81 ec ac 00 00 00    	sub    $0xac,%esp
	envid_t ns_envid = sys_getenvid();
  80004c:	e8 a8 15 00 00       	call   8015f9 <sys_getenvid>
  800051:	89 c3                	mov    %eax,%ebx
	int i, r;

	binaryname = "testinput";
  800053:	c7 05 00 70 80 00 80 	movl   $0x803580,0x807000
  80005a:	35 80 00 

	output_envid = fork();
  80005d:	e8 50 16 00 00       	call   8016b2 <fork>
  800062:	a3 74 70 80 00       	mov    %eax,0x807074
	if (output_envid < 0)
  800067:	85 c0                	test   %eax,%eax
  800069:	79 1c                	jns    800087 <umain+0x47>
		panic("error forking");
  80006b:	c7 44 24 08 8a 35 80 	movl   $0x80358a,0x8(%esp)
  800072:	00 
  800073:	c7 44 24 04 4d 00 00 	movl   $0x4d,0x4(%esp)
  80007a:	00 
  80007b:	c7 04 24 98 35 80 00 	movl   $0x803598,(%esp)
  800082:	e8 f5 05 00 00       	call   80067c <_panic>
	else if (output_envid == 0) {
  800087:	85 c0                	test   %eax,%eax
  800089:	75 0d                	jne    800098 <umain+0x58>
		output(ns_envid);
  80008b:	89 1c 24             	mov    %ebx,(%esp)
  80008e:	e8 15 05 00 00       	call   8005a8 <output>
		return;
  800093:	e9 bb 03 00 00       	jmp    800453 <umain+0x413>
	}

	input_envid = fork();
  800098:	e8 15 16 00 00       	call   8016b2 <fork>
  80009d:	a3 78 70 80 00       	mov    %eax,0x807078
	if (input_envid < 0)
  8000a2:	85 c0                	test   %eax,%eax
  8000a4:	79 1c                	jns    8000c2 <umain+0x82>
		panic("error forking");
  8000a6:	c7 44 24 08 8a 35 80 	movl   $0x80358a,0x8(%esp)
  8000ad:	00 
  8000ae:	c7 44 24 04 55 00 00 	movl   $0x55,0x4(%esp)
  8000b5:	00 
  8000b6:	c7 04 24 98 35 80 00 	movl   $0x803598,(%esp)
  8000bd:	e8 ba 05 00 00       	call   80067c <_panic>
	else if (input_envid == 0) {
  8000c2:	85 c0                	test   %eax,%eax
  8000c4:	75 0f                	jne    8000d5 <umain+0x95>
		input(ns_envid);
  8000c6:	89 1c 24             	mov    %ebx,(%esp)
  8000c9:	e8 32 04 00 00       	call   800500 <input>
  8000ce:	66 90                	xchg   %ax,%ax
  8000d0:	e9 7e 03 00 00       	jmp    800453 <umain+0x413>
		return;
	}

	cprintf("Sending ARP announcement...\n");
  8000d5:	c7 04 24 a8 35 80 00 	movl   $0x8035a8,(%esp)
  8000dc:	e8 60 06 00 00       	call   800741 <cprintf>
	// with ARP requests.  Ideally, we would use gratuitous ARP
	// for this, but QEMU's ARP implementation is dumb and only
	// listens for very specific ARP requests, such as requests
	// for the gateway IP.

	uint8_t mac[6] = {0x52, 0x54, 0x00, 0x12, 0x34, 0x56};
  8000e1:	c6 45 90 52          	movb   $0x52,-0x70(%ebp)
  8000e5:	c6 45 91 54          	movb   $0x54,-0x6f(%ebp)
  8000e9:	c6 45 92 00          	movb   $0x0,-0x6e(%ebp)
  8000ed:	c6 45 93 12          	movb   $0x12,-0x6d(%ebp)
  8000f1:	c6 45 94 34          	movb   $0x34,-0x6c(%ebp)
  8000f5:	c6 45 95 56          	movb   $0x56,-0x6b(%ebp)
	uint32_t myip = inet_addr(IP);
  8000f9:	c7 04 24 c5 35 80 00 	movl   $0x8035c5,(%esp)
  800100:	e8 bb 31 00 00       	call   8032c0 <inet_addr>
  800105:	89 45 e4             	mov    %eax,-0x1c(%ebp)
	uint32_t gwip = inet_addr(DEFAULT);
  800108:	c7 04 24 cf 35 80 00 	movl   $0x8035cf,(%esp)
  80010f:	e8 ac 31 00 00       	call   8032c0 <inet_addr>
  800114:	89 45 e0             	mov    %eax,-0x20(%ebp)
	int r;

	if ((r = sys_page_alloc(0, pkt, PTE_P|PTE_U|PTE_W)) < 0)
  800117:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  80011e:	00 
  80011f:	c7 44 24 04 00 b0 fe 	movl   $0xffeb000,0x4(%esp)
  800126:	0f 
  800127:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80012e:	e8 33 14 00 00       	call   801566 <sys_page_alloc>
  800133:	85 c0                	test   %eax,%eax
  800135:	79 20                	jns    800157 <umain+0x117>
		panic("sys_page_map: %e", r);
  800137:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80013b:	c7 44 24 08 d8 35 80 	movl   $0x8035d8,0x8(%esp)
  800142:	00 
  800143:	c7 44 24 04 19 00 00 	movl   $0x19,0x4(%esp)
  80014a:	00 
  80014b:	c7 04 24 98 35 80 00 	movl   $0x803598,(%esp)
  800152:	e8 25 05 00 00       	call   80067c <_panic>

	struct etharp_hdr *arp = (struct etharp_hdr*)pkt->jp_data;
  800157:	bb 04 b0 fe 0f       	mov    $0xffeb004,%ebx
	pkt->jp_len = sizeof(*arp);
  80015c:	c7 05 00 b0 fe 0f 2a 	movl   $0x2a,0xffeb000
  800163:	00 00 00 

	memset(arp->ethhdr.dest.addr, 0xff, ETHARP_HWADDR_LEN);
  800166:	c7 44 24 08 06 00 00 	movl   $0x6,0x8(%esp)
  80016d:	00 
  80016e:	c7 44 24 04 ff 00 00 	movl   $0xff,0x4(%esp)
  800175:	00 
  800176:	c7 04 24 04 b0 fe 0f 	movl   $0xffeb004,(%esp)
  80017d:	e8 e4 0d 00 00       	call   800f66 <memset>
	memcpy(arp->ethhdr.src.addr,  mac,  ETHARP_HWADDR_LEN);
  800182:	c7 44 24 08 06 00 00 	movl   $0x6,0x8(%esp)
  800189:	00 
  80018a:	8d 75 90             	lea    -0x70(%ebp),%esi
  80018d:	89 74 24 04          	mov    %esi,0x4(%esp)
  800191:	c7 04 24 0a b0 fe 0f 	movl   $0xffeb00a,(%esp)
  800198:	e8 a4 0e 00 00       	call   801041 <memcpy>
	arp->ethhdr.type = htons(ETHTYPE_ARP);
  80019d:	c7 04 24 06 08 00 00 	movl   $0x806,(%esp)
  8001a4:	e8 fa 2e 00 00       	call   8030a3 <htons>
  8001a9:	66 89 43 0c          	mov    %ax,0xc(%ebx)
	arp->hwtype = htons(1); // Ethernet
  8001ad:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  8001b4:	e8 ea 2e 00 00       	call   8030a3 <htons>
  8001b9:	66 89 43 0e          	mov    %ax,0xe(%ebx)
	arp->proto = htons(ETHTYPE_IP);
  8001bd:	c7 04 24 00 08 00 00 	movl   $0x800,(%esp)
  8001c4:	e8 da 2e 00 00       	call   8030a3 <htons>
  8001c9:	66 89 43 10          	mov    %ax,0x10(%ebx)
	arp->_hwlen_protolen = htons((ETHARP_HWADDR_LEN << 8) | 4);
  8001cd:	c7 04 24 04 06 00 00 	movl   $0x604,(%esp)
  8001d4:	e8 ca 2e 00 00       	call   8030a3 <htons>
  8001d9:	66 89 43 12          	mov    %ax,0x12(%ebx)
	arp->opcode = htons(ARP_REQUEST);
  8001dd:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  8001e4:	e8 ba 2e 00 00       	call   8030a3 <htons>
  8001e9:	66 89 43 14          	mov    %ax,0x14(%ebx)
	memcpy(arp->shwaddr.addr,  mac,   ETHARP_HWADDR_LEN);
  8001ed:	c7 44 24 08 06 00 00 	movl   $0x6,0x8(%esp)
  8001f4:	00 
  8001f5:	89 74 24 04          	mov    %esi,0x4(%esp)
  8001f9:	c7 04 24 1a b0 fe 0f 	movl   $0xffeb01a,(%esp)
  800200:	e8 3c 0e 00 00       	call   801041 <memcpy>
	memcpy(arp->sipaddr.addrw, &myip, 4);
  800205:	c7 44 24 08 04 00 00 	movl   $0x4,0x8(%esp)
  80020c:	00 
  80020d:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  800210:	89 44 24 04          	mov    %eax,0x4(%esp)
  800214:	c7 04 24 20 b0 fe 0f 	movl   $0xffeb020,(%esp)
  80021b:	e8 21 0e 00 00       	call   801041 <memcpy>
	memset(arp->dhwaddr.addr,  0x00,  ETHARP_HWADDR_LEN);
  800220:	c7 44 24 08 06 00 00 	movl   $0x6,0x8(%esp)
  800227:	00 
  800228:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  80022f:	00 
  800230:	c7 04 24 24 b0 fe 0f 	movl   $0xffeb024,(%esp)
  800237:	e8 2a 0d 00 00       	call   800f66 <memset>
	memcpy(arp->dipaddr.addrw, &gwip, 4);
  80023c:	c7 44 24 08 04 00 00 	movl   $0x4,0x8(%esp)
  800243:	00 
  800244:	8d 45 e0             	lea    -0x20(%ebp),%eax
  800247:	89 44 24 04          	mov    %eax,0x4(%esp)
  80024b:	c7 04 24 2a b0 fe 0f 	movl   $0xffeb02a,(%esp)
  800252:	e8 ea 0d 00 00       	call   801041 <memcpy>

	ipc_send(output_envid, NSREQ_OUTPUT, pkt, PTE_P|PTE_W|PTE_U);
  800257:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  80025e:	00 
  80025f:	c7 44 24 08 00 b0 fe 	movl   $0xffeb000,0x8(%esp)
  800266:	0f 
  800267:	c7 44 24 04 0b 00 00 	movl   $0xb,0x4(%esp)
  80026e:	00 
  80026f:	a1 74 70 80 00       	mov    0x807074,%eax
  800274:	89 04 24             	mov    %eax,(%esp)
  800277:	e8 14 18 00 00       	call   801a90 <ipc_send>
	sys_page_unmap(0, pkt);
  80027c:	c7 44 24 04 00 b0 fe 	movl   $0xffeb000,0x4(%esp)
  800283:	0f 
  800284:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80028b:	e8 1a 12 00 00       	call   8014aa <sys_page_unmap>
	}

	cprintf("Sending ARP announcement...\n");
	announce();

	cprintf("Waiting for packets...\n");
  800290:	c7 04 24 e9 35 80 00 	movl   $0x8035e9,(%esp)
  800297:	e8 a5 04 00 00       	call   800741 <cprintf>
	while (1) {
		envid_t whom;
		int perm;

		int32_t req = ipc_recv((int32_t *)&whom, pkt, &perm);
  80029c:	8d 45 e0             	lea    -0x20(%ebp),%eax
  80029f:	89 85 74 ff ff ff    	mov    %eax,-0x8c(%ebp)
	char buf[80];
	char *end = buf + sizeof(buf);
	char *out = NULL;
	for (i = 0; i < len; i++) {
		if (i % 16 == 0)
			out = buf + snprintf(buf, end - buf,
  8002a5:	89 b5 70 ff ff ff    	mov    %esi,-0x90(%ebp)
  8002ab:	8b 85 74 ff ff ff    	mov    -0x8c(%ebp),%eax
  8002b1:	29 f0                	sub    %esi,%eax
  8002b3:	89 85 7c ff ff ff    	mov    %eax,-0x84(%ebp)
	cprintf("Waiting for packets...\n");
	while (1) {
		envid_t whom;
		int perm;

		int32_t req = ipc_recv((int32_t *)&whom, pkt, &perm);
  8002b9:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  8002bc:	89 44 24 08          	mov    %eax,0x8(%esp)
  8002c0:	c7 44 24 04 00 b0 fe 	movl   $0xffeb000,0x4(%esp)
  8002c7:	0f 
  8002c8:	8d 45 e0             	lea    -0x20(%ebp),%eax
  8002cb:	89 04 24             	mov    %eax,(%esp)
  8002ce:	e8 2f 18 00 00       	call   801b02 <ipc_recv>
  8002d3:	89 c3                	mov    %eax,%ebx
        cprintf("Received from: %x\n", whom);
  8002d5:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8002d8:	89 44 24 04          	mov    %eax,0x4(%esp)
  8002dc:	c7 04 24 01 36 80 00 	movl   $0x803601,(%esp)
  8002e3:	e8 59 04 00 00       	call   800741 <cprintf>
		if (req < 0)
  8002e8:	85 db                	test   %ebx,%ebx
  8002ea:	79 20                	jns    80030c <umain+0x2cc>
			panic("ipc_recv: %e", req);
  8002ec:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8002f0:	c7 44 24 08 14 36 80 	movl   $0x803614,0x8(%esp)
  8002f7:	00 
  8002f8:	c7 44 24 04 66 00 00 	movl   $0x66,0x4(%esp)
  8002ff:	00 
  800300:	c7 04 24 98 35 80 00 	movl   $0x803598,(%esp)
  800307:	e8 70 03 00 00       	call   80067c <_panic>
		if (whom != input_envid)
  80030c:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80030f:	3b 05 78 70 80 00    	cmp    0x807078,%eax
  800315:	74 20                	je     800337 <umain+0x2f7>
			panic("IPC from unexpected environment %08x", whom);
  800317:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80031b:	c7 44 24 08 50 36 80 	movl   $0x803650,0x8(%esp)
  800322:	00 
  800323:	c7 44 24 04 68 00 00 	movl   $0x68,0x4(%esp)
  80032a:	00 
  80032b:	c7 04 24 98 35 80 00 	movl   $0x803598,(%esp)
  800332:	e8 45 03 00 00       	call   80067c <_panic>
		if (req != NSREQ_INPUT)
  800337:	83 fb 0a             	cmp    $0xa,%ebx
  80033a:	74 20                	je     80035c <umain+0x31c>
			panic("Unexpected IPC %d", req);
  80033c:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  800340:	c7 44 24 08 21 36 80 	movl   $0x803621,0x8(%esp)
  800347:	00 
  800348:	c7 44 24 04 6a 00 00 	movl   $0x6a,0x4(%esp)
  80034f:	00 
  800350:	c7 04 24 98 35 80 00 	movl   $0x803598,(%esp)
  800357:	e8 20 03 00 00       	call   80067c <_panic>
		hexdump("input: ", pkt->jp_data, pkt->jp_len);
  80035c:	a1 00 b0 fe 0f       	mov    0xffeb000,%eax
  800361:	89 45 84             	mov    %eax,-0x7c(%ebp)
{
	int i;
	char buf[80];
	char *end = buf + sizeof(buf);
	char *out = NULL;
	for (i = 0; i < len; i++) {
  800364:	85 c0                	test   %eax,%eax
  800366:	0f 8e d6 00 00 00    	jle    800442 <umain+0x402>
  80036c:	be 00 00 00 00       	mov    $0x0,%esi
  800371:	bb 00 00 00 00       	mov    $0x0,%ebx
		if (i % 16 == 0)
			out = buf + snprintf(buf, end - buf,
					     "%s%04x   ", prefix, i);
		out += snprintf(out, end - out, "%02x", ((uint8_t*)data)[i]);
		if (i % 16 == 15 || i == len - 1)
  800376:	83 e8 01             	sub    $0x1,%eax
  800379:	89 45 80             	mov    %eax,-0x80(%ebp)
{
	int i;
	char buf[80];
	char *end = buf + sizeof(buf);
	char *out = NULL;
	for (i = 0; i < len; i++) {
  80037c:	89 df                	mov    %ebx,%edi
		if (i % 16 == 0)
  80037e:	f6 c3 0f             	test   $0xf,%bl
  800381:	75 2e                	jne    8003b1 <umain+0x371>
			out = buf + snprintf(buf, end - buf,
  800383:	89 5c 24 10          	mov    %ebx,0x10(%esp)
  800387:	c7 44 24 0c 33 36 80 	movl   $0x803633,0xc(%esp)
  80038e:	00 
  80038f:	c7 44 24 08 3b 36 80 	movl   $0x80363b,0x8(%esp)
  800396:	00 
  800397:	8b 85 7c ff ff ff    	mov    -0x84(%ebp),%eax
  80039d:	89 44 24 04          	mov    %eax,0x4(%esp)
  8003a1:	8d 45 90             	lea    -0x70(%ebp),%eax
  8003a4:	89 04 24             	mov    %eax,(%esp)
  8003a7:	e8 bd 09 00 00       	call   800d69 <snprintf>
  8003ac:	8d 75 90             	lea    -0x70(%ebp),%esi
  8003af:	01 c6                	add    %eax,%esi
					     "%s%04x   ", prefix, i);
		out += snprintf(out, end - out, "%02x", ((uint8_t*)data)[i]);
  8003b1:	0f b6 87 04 b0 fe 0f 	movzbl 0xffeb004(%edi),%eax
  8003b8:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8003bc:	c7 44 24 08 45 36 80 	movl   $0x803645,0x8(%esp)
  8003c3:	00 
  8003c4:	8b 85 74 ff ff ff    	mov    -0x8c(%ebp),%eax
  8003ca:	29 f0                	sub    %esi,%eax
  8003cc:	89 44 24 04          	mov    %eax,0x4(%esp)
  8003d0:	89 34 24             	mov    %esi,(%esp)
  8003d3:	e8 91 09 00 00       	call   800d69 <snprintf>
  8003d8:	01 c6                	add    %eax,%esi
		if (i % 16 == 15 || i == len - 1)
  8003da:	89 d8                	mov    %ebx,%eax
  8003dc:	c1 f8 1f             	sar    $0x1f,%eax
  8003df:	c1 e8 1c             	shr    $0x1c,%eax
  8003e2:	8d 3c 03             	lea    (%ebx,%eax,1),%edi
  8003e5:	83 e7 0f             	and    $0xf,%edi
  8003e8:	29 c7                	sub    %eax,%edi
  8003ea:	83 ff 0f             	cmp    $0xf,%edi
  8003ed:	74 05                	je     8003f4 <umain+0x3b4>
  8003ef:	3b 5d 80             	cmp    -0x80(%ebp),%ebx
  8003f2:	75 1f                	jne    800413 <umain+0x3d3>
			cprintf("%.*s\n", out - buf, buf);
  8003f4:	8d 45 90             	lea    -0x70(%ebp),%eax
  8003f7:	89 44 24 08          	mov    %eax,0x8(%esp)
  8003fb:	89 f0                	mov    %esi,%eax
  8003fd:	2b 85 70 ff ff ff    	sub    -0x90(%ebp),%eax
  800403:	89 44 24 04          	mov    %eax,0x4(%esp)
  800407:	c7 04 24 4a 36 80 00 	movl   $0x80364a,(%esp)
  80040e:	e8 2e 03 00 00       	call   800741 <cprintf>
		if (i % 2 == 1)
  800413:	89 d8                	mov    %ebx,%eax
  800415:	c1 e8 1f             	shr    $0x1f,%eax
  800418:	8d 14 03             	lea    (%ebx,%eax,1),%edx
  80041b:	83 e2 01             	and    $0x1,%edx
  80041e:	29 c2                	sub    %eax,%edx
  800420:	83 fa 01             	cmp    $0x1,%edx
  800423:	75 06                	jne    80042b <umain+0x3eb>
			*(out++) = ' ';
  800425:	c6 06 20             	movb   $0x20,(%esi)
  800428:	83 c6 01             	add    $0x1,%esi
		if (i % 16 == 7)
  80042b:	83 ff 07             	cmp    $0x7,%edi
  80042e:	75 06                	jne    800436 <umain+0x3f6>
			*(out++) = ' ';
  800430:	c6 06 20             	movb   $0x20,(%esi)
  800433:	83 c6 01             	add    $0x1,%esi
{
	int i;
	char buf[80];
	char *end = buf + sizeof(buf);
	char *out = NULL;
	for (i = 0; i < len; i++) {
  800436:	83 c3 01             	add    $0x1,%ebx
  800439:	39 5d 84             	cmp    %ebx,-0x7c(%ebp)
  80043c:	0f 8f 3a ff ff ff    	jg     80037c <umain+0x33c>
		if (whom != input_envid)
			panic("IPC from unexpected environment %08x", whom);
		if (req != NSREQ_INPUT)
			panic("Unexpected IPC %d", req);
		hexdump("input: ", pkt->jp_data, pkt->jp_len);
		cprintf("\n");
  800442:	c7 04 24 ff 35 80 00 	movl   $0x8035ff,(%esp)
  800449:	e8 f3 02 00 00       	call   800741 <cprintf>
	}
  80044e:	e9 66 fe ff ff       	jmp    8002b9 <umain+0x279>
}
  800453:	81 c4 ac 00 00 00    	add    $0xac,%esp
  800459:	5b                   	pop    %ebx
  80045a:	5e                   	pop    %esi
  80045b:	5f                   	pop    %edi
  80045c:	5d                   	pop    %ebp
  80045d:	c3                   	ret    
	...

00800460 <timer>:
#include "ns.h"

void
timer(envid_t ns_envid, uint32_t initial_to) {
  800460:	55                   	push   %ebp
  800461:	89 e5                	mov    %esp,%ebp
  800463:	57                   	push   %edi
  800464:	56                   	push   %esi
  800465:	53                   	push   %ebx
  800466:	83 ec 2c             	sub    $0x2c,%esp
  800469:	8b 75 08             	mov    0x8(%ebp),%esi
	uint32_t stop = sys_time_msec() + initial_to;
  80046c:	e8 2e 0e 00 00       	call   80129f <sys_time_msec>
  800471:	89 c3                	mov    %eax,%ebx
  800473:	03 5d 0c             	add    0xc(%ebp),%ebx

	binaryname = "ns_timer";
  800476:	c7 05 00 70 80 00 75 	movl   $0x803675,0x807000
  80047d:	36 80 00 

		ipc_send(ns_envid, NSREQ_TIMER, 0, 0);

		while (1) {
			uint32_t to, whom;
			to = ipc_recv((int32_t *) &whom, 0, 0);
  800480:	8d 7d e4             	lea    -0x1c(%ebp),%edi
  800483:	eb 05                	jmp    80048a <timer+0x2a>

	binaryname = "ns_timer";

	while (1) {
		while(sys_time_msec() < stop) {
			sys_yield();
  800485:	e8 3b 11 00 00       	call   8015c5 <sys_yield>
	uint32_t stop = sys_time_msec() + initial_to;

	binaryname = "ns_timer";

	while (1) {
		while(sys_time_msec() < stop) {
  80048a:	e8 10 0e 00 00       	call   80129f <sys_time_msec>
  80048f:	39 c3                	cmp    %eax,%ebx
  800491:	77 f2                	ja     800485 <timer+0x25>
			sys_yield();
		}

		ipc_send(ns_envid, NSREQ_TIMER, 0, 0);
  800493:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80049a:	00 
  80049b:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8004a2:	00 
  8004a3:	c7 44 24 04 0c 00 00 	movl   $0xc,0x4(%esp)
  8004aa:	00 
  8004ab:	89 34 24             	mov    %esi,(%esp)
  8004ae:	e8 dd 15 00 00       	call   801a90 <ipc_send>

		while (1) {
			uint32_t to, whom;
			to = ipc_recv((int32_t *) &whom, 0, 0);
  8004b3:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8004ba:	00 
  8004bb:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  8004c2:	00 
  8004c3:	89 3c 24             	mov    %edi,(%esp)
  8004c6:	e8 37 16 00 00       	call   801b02 <ipc_recv>
  8004cb:	89 c3                	mov    %eax,%ebx

			if (whom != ns_envid) {
  8004cd:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8004d0:	39 c6                	cmp    %eax,%esi
  8004d2:	74 12                	je     8004e6 <timer+0x86>
				cprintf("NS TIMER: timer thread got IPC message from env %x not NS\n", whom);
  8004d4:	89 44 24 04          	mov    %eax,0x4(%esp)
  8004d8:	c7 04 24 80 36 80 00 	movl   $0x803680,(%esp)
  8004df:	e8 5d 02 00 00       	call   800741 <cprintf>
				continue;
			}

			stop = sys_time_msec() + to;
			break;
		}
  8004e4:	eb cd                	jmp    8004b3 <timer+0x53>
			if (whom != ns_envid) {
				cprintf("NS TIMER: timer thread got IPC message from env %x not NS\n", whom);
				continue;
			}

			stop = sys_time_msec() + to;
  8004e6:	e8 b4 0d 00 00       	call   80129f <sys_time_msec>
  8004eb:	8d 1c 18             	lea    (%eax,%ebx,1),%ebx
  8004ee:	66 90                	xchg   %ax,%ax
  8004f0:	eb 98                	jmp    80048a <timer+0x2a>
	...

00800500 <input>:

extern union Nsipc nsipcbuf;

void
input(envid_t ns_envid)
{
  800500:	55                   	push   %ebp
  800501:	89 e5                	mov    %esp,%ebp
  800503:	56                   	push   %esi
  800504:	53                   	push   %ebx
  800505:	83 ec 10             	sub    $0x10,%esp
  800508:	8b 75 08             	mov    0x8(%ebp),%esi
    int r=0;
    int n=0;
	struct jif_pkt *pkt = (struct jif_pkt *)0x00100000;
    envid_t envid   = sys_getenvid();
  80050b:	e8 e9 10 00 00       	call   8015f9 <sys_getenvid>
	binaryname = "ns_input";
  800510:	c7 05 00 70 80 00 bb 	movl   $0x8036bb,0x807000
  800517:	36 80 00 
	// 	- read a packet from the device driver
	//	- send it to the network server
	// Hint: When you IPC a page to the network server, it will be
	// reading from it for a while, so don't immediately receive
	// another packet in to the same physical page.
    if((r=sys_page_alloc(0, (void *)pkt, PTE_P|PTE_W|PTE_U))<0)
  80051a:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  800521:	00 
  800522:	c7 44 24 04 00 00 10 	movl   $0x100000,0x4(%esp)
  800529:	00 
  80052a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800531:	e8 30 10 00 00       	call   801566 <sys_page_alloc>
        panic("sys_page_map: error: %x\n", r);

    while (1) {
        if((n=sys_ns_recv(pkt->jp_data, PGSIZE-sizeof(struct jif_pkt)))>0) {
            if (n != 11) {
            pkt->jp_len = n;
  800536:	bb 00 00 10 00       	mov    $0x100000,%ebx
	// 	- read a packet from the device driver
	//	- send it to the network server
	// Hint: When you IPC a page to the network server, it will be
	// reading from it for a while, so don't immediately receive
	// another packet in to the same physical page.
    if((r=sys_page_alloc(0, (void *)pkt, PTE_P|PTE_W|PTE_U))<0)
  80053b:	85 c0                	test   %eax,%eax
  80053d:	79 20                	jns    80055f <input+0x5f>
        panic("sys_page_map: error: %x\n", r);
  80053f:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800543:	c7 44 24 08 c4 36 80 	movl   $0x8036c4,0x8(%esp)
  80054a:	00 
  80054b:	c7 44 24 04 15 00 00 	movl   $0x15,0x4(%esp)
  800552:	00 
  800553:	c7 04 24 dd 36 80 00 	movl   $0x8036dd,(%esp)
  80055a:	e8 1d 01 00 00       	call   80067c <_panic>

    while (1) {
        if((n=sys_ns_recv(pkt->jp_data, PGSIZE-sizeof(struct jif_pkt)))>0) {
  80055f:	c7 44 24 04 fc 0f 00 	movl   $0xffc,0x4(%esp)
  800566:	00 
  800567:	c7 04 24 04 00 10 00 	movl   $0x100004,(%esp)
  80056e:	e8 c0 0c 00 00       	call   801233 <sys_ns_recv>
  800573:	85 c0                	test   %eax,%eax
  800575:	7e 28                	jle    80059f <input+0x9f>
            if (n != 11) {
  800577:	83 f8 0b             	cmp    $0xb,%eax
  80057a:	74 1e                	je     80059a <input+0x9a>
            pkt->jp_len = n;
  80057c:	89 03                	mov    %eax,(%ebx)
            ipc_send(ns_envid, NSREQ_INPUT, (void *)pkt, PTE_P|PTE_W|PTE_U);
  80057e:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  800585:	00 
  800586:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  80058a:	c7 44 24 04 0a 00 00 	movl   $0xa,0x4(%esp)
  800591:	00 
  800592:	89 34 24             	mov    %esi,(%esp)
  800595:	e8 f6 14 00 00       	call   801a90 <ipc_send>
            }
            sys_yield();
  80059a:	e8 26 10 00 00       	call   8015c5 <sys_yield>
        } 
        sys_yield();
  80059f:	e8 21 10 00 00       	call   8015c5 <sys_yield>
    }
  8005a4:	eb b9                	jmp    80055f <input+0x5f>
	...

008005a8 <output>:

extern union Nsipc nsipcbuf;

void
output(envid_t ns_envid)
{
  8005a8:	55                   	push   %ebp
  8005a9:	89 e5                	mov    %esp,%ebp
  8005ab:	53                   	push   %ebx
  8005ac:	83 ec 24             	sub    $0x24,%esp
    int r=0;
    envid_t from=0;
  8005af:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
	binaryname = "ns_output";
  8005b6:	c7 05 00 70 80 00 e9 	movl   $0x8036e9,0x807000
  8005bd:	36 80 00 

	// LAB 6: Your code here:
	// 	- read a packet from the network server
	//	- send the packet to the device driver
    while(1) {
        if((r=ipc_recv(&from, &nsipcbuf.pkt, NULL))==NSREQ_OUTPUT) {
  8005c0:	8d 5d f4             	lea    -0xc(%ebp),%ebx
  8005c3:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8005ca:	00 
  8005cb:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  8005d2:	00 
  8005d3:	89 1c 24             	mov    %ebx,(%esp)
  8005d6:	e8 27 15 00 00       	call   801b02 <ipc_recv>
  8005db:	83 f8 0b             	cmp    $0xb,%eax
  8005de:	75 17                	jne    8005f7 <output+0x4f>
            //cprintf("\nBuffer: %s Len: %d From: %x nsid: %x", &nsipcbuf.pkt.jp_data, nsipcbuf.pkt.jp_len, from, ns_envid);
            //cprintf("\nSending to driver");
            r   = sys_ns_send(&nsipcbuf.pkt.jp_data, nsipcbuf.pkt.jp_len);
  8005e0:	a1 00 60 80 00       	mov    0x806000,%eax
  8005e5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8005e9:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  8005f0:	e8 74 0c 00 00       	call   801269 <sys_ns_send>
  8005f5:	eb cc                	jmp    8005c3 <output+0x1b>
        } else {
            cprintf("output: error %x\n", r);
  8005f7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8005fb:	c7 04 24 f3 36 80 00 	movl   $0x8036f3,(%esp)
  800602:	e8 3a 01 00 00       	call   800741 <cprintf>
            sys_yield();
  800607:	e8 b9 0f 00 00       	call   8015c5 <sys_yield>
  80060c:	eb b5                	jmp    8005c3 <output+0x1b>
	...

00800610 <libmain>:
volatile struct Env *env;
char *binaryname = "(PROGRAM NAME UNKNOWN)";

void
libmain(int argc, char **argv)
{
  800610:	55                   	push   %ebp
  800611:	89 e5                	mov    %esp,%ebp
  800613:	83 ec 18             	sub    $0x18,%esp
  800616:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  800619:	89 75 fc             	mov    %esi,-0x4(%ebp)
  80061c:	8b 75 08             	mov    0x8(%ebp),%esi
  80061f:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	// set env to point at our env structure in envs[].
	// LAB 3: Your code here.
  envid_t envid   = sys_getenvid();
  800622:	e8 d2 0f 00 00       	call   8015f9 <sys_getenvid>
	env = &envs [ENVX(envid)];
  800627:	25 ff 03 00 00       	and    $0x3ff,%eax
  80062c:	6b c0 7c             	imul   $0x7c,%eax,%eax
  80062f:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  800634:	a3 8c 70 80 00       	mov    %eax,0x80708c

	// save the name of the program so that panic() can use it
	if (argc > 0)
  800639:	85 f6                	test   %esi,%esi
  80063b:	7e 07                	jle    800644 <libmain+0x34>
		binaryname = argv[0];
  80063d:	8b 03                	mov    (%ebx),%eax
  80063f:	a3 00 70 80 00       	mov    %eax,0x807000

	// call user main routine
	umain(argc, argv);
  800644:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800648:	89 34 24             	mov    %esi,(%esp)
  80064b:	e8 f0 f9 ff ff       	call   800040 <umain>

	// exit gracefully
	exit();
  800650:	e8 0b 00 00 00       	call   800660 <exit>
}
  800655:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  800658:	8b 75 fc             	mov    -0x4(%ebp),%esi
  80065b:	89 ec                	mov    %ebp,%esp
  80065d:	5d                   	pop    %ebp
  80065e:	c3                   	ret    
	...

00800660 <exit>:

#include <inc/lib.h>

void
exit(void)
{
  800660:	55                   	push   %ebp
  800661:	89 e5                	mov    %esp,%ebp
  800663:	83 ec 18             	sub    $0x18,%esp
	close_all();
  800666:	e8 2e 1a 00 00       	call   802099 <close_all>
	sys_env_destroy(0);
  80066b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800672:	e8 b6 0f 00 00       	call   80162d <sys_env_destroy>
}
  800677:	c9                   	leave  
  800678:	c3                   	ret    
  800679:	00 00                	add    %al,(%eax)
	...

0080067c <_panic>:
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
{
  80067c:	55                   	push   %ebp
  80067d:	89 e5                	mov    %esp,%ebp
  80067f:	53                   	push   %ebx
  800680:	83 ec 14             	sub    $0x14,%esp
 * Panic is called on unresolvable fatal errors.
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
  800683:	8d 5d 14             	lea    0x14(%ebp),%ebx
	va_list ap;

	va_start(ap, fmt);

	// Print the panic message
	if (argv0)
  800686:	a1 90 70 80 00       	mov    0x807090,%eax
  80068b:	85 c0                	test   %eax,%eax
  80068d:	74 10                	je     80069f <_panic+0x23>
		cprintf("%s: ", argv0);
  80068f:	89 44 24 04          	mov    %eax,0x4(%esp)
  800693:	c7 04 24 1c 37 80 00 	movl   $0x80371c,(%esp)
  80069a:	e8 a2 00 00 00       	call   800741 <cprintf>
	cprintf("user panic in %s at %s:%d: ", binaryname, file, line);
  80069f:	8b 45 0c             	mov    0xc(%ebp),%eax
  8006a2:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8006a6:	8b 45 08             	mov    0x8(%ebp),%eax
  8006a9:	89 44 24 08          	mov    %eax,0x8(%esp)
  8006ad:	a1 00 70 80 00       	mov    0x807000,%eax
  8006b2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8006b6:	c7 04 24 21 37 80 00 	movl   $0x803721,(%esp)
  8006bd:	e8 7f 00 00 00       	call   800741 <cprintf>
	vcprintf(fmt, ap);
  8006c2:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8006c6:	8b 45 10             	mov    0x10(%ebp),%eax
  8006c9:	89 04 24             	mov    %eax,(%esp)
  8006cc:	e8 0f 00 00 00       	call   8006e0 <vcprintf>
	cprintf("\n");
  8006d1:	c7 04 24 ff 35 80 00 	movl   $0x8035ff,(%esp)
  8006d8:	e8 64 00 00 00       	call   800741 <cprintf>

	// Cause a breakpoint exception
	while (1)
		asm volatile("int3");
  8006dd:	cc                   	int3   
  8006de:	eb fd                	jmp    8006dd <_panic+0x61>

008006e0 <vcprintf>:
	b->cnt++;
}

int
vcprintf(const char *fmt, va_list ap)
{
  8006e0:	55                   	push   %ebp
  8006e1:	89 e5                	mov    %esp,%ebp
  8006e3:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct printbuf b;

	b.idx = 0;
  8006e9:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  8006f0:	00 00 00 
	b.cnt = 0;
  8006f3:	c7 85 f4 fe ff ff 00 	movl   $0x0,-0x10c(%ebp)
  8006fa:	00 00 00 
	vprintfmt((void*)putch, &b, fmt, ap);
  8006fd:	8b 45 0c             	mov    0xc(%ebp),%eax
  800700:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800704:	8b 45 08             	mov    0x8(%ebp),%eax
  800707:	89 44 24 08          	mov    %eax,0x8(%esp)
  80070b:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  800711:	89 44 24 04          	mov    %eax,0x4(%esp)
  800715:	c7 04 24 5b 07 80 00 	movl   $0x80075b,(%esp)
  80071c:	e8 cc 01 00 00       	call   8008ed <vprintfmt>
	sys_cputs(b.buf, b.idx);
  800721:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  800727:	89 44 24 04          	mov    %eax,0x4(%esp)
  80072b:	8d 85 f8 fe ff ff    	lea    -0x108(%ebp),%eax
  800731:	89 04 24             	mov    %eax,(%esp)
  800734:	e8 c7 0a 00 00       	call   801200 <sys_cputs>

	return b.cnt;
}
  800739:	8b 85 f4 fe ff ff    	mov    -0x10c(%ebp),%eax
  80073f:	c9                   	leave  
  800740:	c3                   	ret    

00800741 <cprintf>:

int
cprintf(const char *fmt, ...)
{
  800741:	55                   	push   %ebp
  800742:	89 e5                	mov    %esp,%ebp
  800744:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
cprintf(const char *fmt, ...)
  800747:	8d 45 0c             	lea    0xc(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vcprintf(fmt, ap);
  80074a:	89 44 24 04          	mov    %eax,0x4(%esp)
  80074e:	8b 45 08             	mov    0x8(%ebp),%eax
  800751:	89 04 24             	mov    %eax,(%esp)
  800754:	e8 87 ff ff ff       	call   8006e0 <vcprintf>
	va_end(ap);

	return cnt;
}
  800759:	c9                   	leave  
  80075a:	c3                   	ret    

0080075b <putch>:
};


static void
putch(int ch, struct printbuf *b)
{
  80075b:	55                   	push   %ebp
  80075c:	89 e5                	mov    %esp,%ebp
  80075e:	53                   	push   %ebx
  80075f:	83 ec 14             	sub    $0x14,%esp
  800762:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  800765:	8b 03                	mov    (%ebx),%eax
  800767:	8b 55 08             	mov    0x8(%ebp),%edx
  80076a:	88 54 03 08          	mov    %dl,0x8(%ebx,%eax,1)
  80076e:	83 c0 01             	add    $0x1,%eax
  800771:	89 03                	mov    %eax,(%ebx)
	if (b->idx == 256-1) {
  800773:	3d ff 00 00 00       	cmp    $0xff,%eax
  800778:	75 19                	jne    800793 <putch+0x38>
		sys_cputs(b->buf, b->idx);
  80077a:	c7 44 24 04 ff 00 00 	movl   $0xff,0x4(%esp)
  800781:	00 
  800782:	8d 43 08             	lea    0x8(%ebx),%eax
  800785:	89 04 24             	mov    %eax,(%esp)
  800788:	e8 73 0a 00 00       	call   801200 <sys_cputs>
		b->idx = 0;
  80078d:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
	}
	b->cnt++;
  800793:	83 43 04 01          	addl   $0x1,0x4(%ebx)
}
  800797:	83 c4 14             	add    $0x14,%esp
  80079a:	5b                   	pop    %ebx
  80079b:	5d                   	pop    %ebp
  80079c:	c3                   	ret    
  80079d:	00 00                	add    %al,(%eax)
	...

008007a0 <printnum>:
 * using specified putch function and associated pointer putdat.
 */
static void
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
  8007a0:	55                   	push   %ebp
  8007a1:	89 e5                	mov    %esp,%ebp
  8007a3:	57                   	push   %edi
  8007a4:	56                   	push   %esi
  8007a5:	53                   	push   %ebx
  8007a6:	83 ec 4c             	sub    $0x4c,%esp
  8007a9:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  8007ac:	89 d6                	mov    %edx,%esi
  8007ae:	8b 45 08             	mov    0x8(%ebp),%eax
  8007b1:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8007b4:	8b 55 0c             	mov    0xc(%ebp),%edx
  8007b7:	89 55 e0             	mov    %edx,-0x20(%ebp)
  8007ba:	8b 45 10             	mov    0x10(%ebp),%eax
  8007bd:	8b 5d 14             	mov    0x14(%ebp),%ebx
  8007c0:	8b 7d 18             	mov    0x18(%ebp),%edi
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  8007c3:	89 45 dc             	mov    %eax,-0x24(%ebp)
  8007c6:	b9 00 00 00 00       	mov    $0x0,%ecx
  8007cb:	39 d1                	cmp    %edx,%ecx
  8007cd:	72 15                	jb     8007e4 <printnum+0x44>
  8007cf:	77 07                	ja     8007d8 <printnum+0x38>
  8007d1:	8b 55 d8             	mov    -0x28(%ebp),%edx
  8007d4:	39 d0                	cmp    %edx,%eax
  8007d6:	76 0c                	jbe    8007e4 <printnum+0x44>
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  8007d8:	83 eb 01             	sub    $0x1,%ebx
  8007db:	85 db                	test   %ebx,%ebx
  8007dd:	8d 76 00             	lea    0x0(%esi),%esi
  8007e0:	7f 61                	jg     800843 <printnum+0xa3>
  8007e2:	eb 70                	jmp    800854 <printnum+0xb4>
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
  8007e4:	89 7c 24 10          	mov    %edi,0x10(%esp)
  8007e8:	83 eb 01             	sub    $0x1,%ebx
  8007eb:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8007ef:	89 44 24 08          	mov    %eax,0x8(%esp)
  8007f3:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  8007f7:	8b 5c 24 0c          	mov    0xc(%esp),%ebx
  8007fb:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  8007fe:	89 5d d4             	mov    %ebx,-0x2c(%ebp)
  800801:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800804:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  800808:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80080f:	00 
  800810:	8b 45 d8             	mov    -0x28(%ebp),%eax
  800813:	89 04 24             	mov    %eax,(%esp)
  800816:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800819:	89 54 24 04          	mov    %edx,0x4(%esp)
  80081d:	e8 de 2a 00 00       	call   803300 <__udivdi3>
  800822:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  800825:	8b 5d d4             	mov    -0x2c(%ebp),%ebx
  800828:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  80082c:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  800830:	89 04 24             	mov    %eax,(%esp)
  800833:	89 54 24 04          	mov    %edx,0x4(%esp)
  800837:	89 f2                	mov    %esi,%edx
  800839:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80083c:	e8 5f ff ff ff       	call   8007a0 <printnum>
  800841:	eb 11                	jmp    800854 <printnum+0xb4>
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
			putch(padc, putdat);
  800843:	89 74 24 04          	mov    %esi,0x4(%esp)
  800847:	89 3c 24             	mov    %edi,(%esp)
  80084a:	ff 55 e4             	call   *-0x1c(%ebp)
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  80084d:	83 eb 01             	sub    $0x1,%ebx
  800850:	85 db                	test   %ebx,%ebx
  800852:	7f ef                	jg     800843 <printnum+0xa3>
			putch(padc, putdat);
	}

	// then print this (the least significant) digit
	putch("0123456789abcdef"[num % base], putdat);
  800854:	89 74 24 04          	mov    %esi,0x4(%esp)
  800858:	8b 74 24 04          	mov    0x4(%esp),%esi
  80085c:	8b 45 dc             	mov    -0x24(%ebp),%eax
  80085f:	89 44 24 08          	mov    %eax,0x8(%esp)
  800863:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80086a:	00 
  80086b:	8b 55 d8             	mov    -0x28(%ebp),%edx
  80086e:	89 14 24             	mov    %edx,(%esp)
  800871:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800874:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800878:	e8 b3 2b 00 00       	call   803430 <__umoddi3>
  80087d:	89 74 24 04          	mov    %esi,0x4(%esp)
  800881:	0f be 80 3d 37 80 00 	movsbl 0x80373d(%eax),%eax
  800888:	89 04 24             	mov    %eax,(%esp)
  80088b:	ff 55 e4             	call   *-0x1c(%ebp)
}
  80088e:	83 c4 4c             	add    $0x4c,%esp
  800891:	5b                   	pop    %ebx
  800892:	5e                   	pop    %esi
  800893:	5f                   	pop    %edi
  800894:	5d                   	pop    %ebp
  800895:	c3                   	ret    

00800896 <getuint>:

// Get an unsigned int of various possible sizes from a varargs list,
// depending on the lflag parameter.
static unsigned long long
getuint(va_list *ap, int lflag)
{
  800896:	55                   	push   %ebp
  800897:	89 e5                	mov    %esp,%ebp
	if (lflag >= 2)
  800899:	83 fa 01             	cmp    $0x1,%edx
  80089c:	7e 0e                	jle    8008ac <getuint+0x16>
		return va_arg(*ap, unsigned long long);
  80089e:	8b 10                	mov    (%eax),%edx
  8008a0:	8d 4a 08             	lea    0x8(%edx),%ecx
  8008a3:	89 08                	mov    %ecx,(%eax)
  8008a5:	8b 02                	mov    (%edx),%eax
  8008a7:	8b 52 04             	mov    0x4(%edx),%edx
  8008aa:	eb 22                	jmp    8008ce <getuint+0x38>
	else if (lflag)
  8008ac:	85 d2                	test   %edx,%edx
  8008ae:	74 10                	je     8008c0 <getuint+0x2a>
		return va_arg(*ap, unsigned long);
  8008b0:	8b 10                	mov    (%eax),%edx
  8008b2:	8d 4a 04             	lea    0x4(%edx),%ecx
  8008b5:	89 08                	mov    %ecx,(%eax)
  8008b7:	8b 02                	mov    (%edx),%eax
  8008b9:	ba 00 00 00 00       	mov    $0x0,%edx
  8008be:	eb 0e                	jmp    8008ce <getuint+0x38>
	else
		return va_arg(*ap, unsigned int);
  8008c0:	8b 10                	mov    (%eax),%edx
  8008c2:	8d 4a 04             	lea    0x4(%edx),%ecx
  8008c5:	89 08                	mov    %ecx,(%eax)
  8008c7:	8b 02                	mov    (%edx),%eax
  8008c9:	ba 00 00 00 00       	mov    $0x0,%edx
}
  8008ce:	5d                   	pop    %ebp
  8008cf:	c3                   	ret    

008008d0 <sprintputch>:
	int cnt;
};

static void
sprintputch(int ch, struct sprintbuf *b)
{
  8008d0:	55                   	push   %ebp
  8008d1:	89 e5                	mov    %esp,%ebp
  8008d3:	8b 45 0c             	mov    0xc(%ebp),%eax
	b->cnt++;
  8008d6:	83 40 08 01          	addl   $0x1,0x8(%eax)
	if (b->buf < b->ebuf)
  8008da:	8b 10                	mov    (%eax),%edx
  8008dc:	3b 50 04             	cmp    0x4(%eax),%edx
  8008df:	73 0a                	jae    8008eb <sprintputch+0x1b>
		*b->buf++ = ch;
  8008e1:	8b 4d 08             	mov    0x8(%ebp),%ecx
  8008e4:	88 0a                	mov    %cl,(%edx)
  8008e6:	83 c2 01             	add    $0x1,%edx
  8008e9:	89 10                	mov    %edx,(%eax)
}
  8008eb:	5d                   	pop    %ebp
  8008ec:	c3                   	ret    

008008ed <vprintfmt>:
// Main function to format and print a string.
void printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...);

void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap)
{
  8008ed:	55                   	push   %ebp
  8008ee:	89 e5                	mov    %esp,%ebp
  8008f0:	57                   	push   %edi
  8008f1:	56                   	push   %esi
  8008f2:	53                   	push   %ebx
  8008f3:	83 ec 5c             	sub    $0x5c,%esp
  8008f6:	8b 7d 08             	mov    0x8(%ebp),%edi
  8008f9:	8b 75 0c             	mov    0xc(%ebp),%esi
  8008fc:	8b 5d 10             	mov    0x10(%ebp),%ebx
		case '#':
			altflag = 1;
			goto reswitch;

		process_precision:
			if (width < 0)
  8008ff:	c7 45 c8 ff ff ff ff 	movl   $0xffffffff,-0x38(%ebp)
  800906:	eb 11                	jmp    800919 <vprintfmt+0x2c>
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
			if (ch == '\0')
  800908:	85 c0                	test   %eax,%eax
  80090a:	0f 84 f9 03 00 00    	je     800d09 <vprintfmt+0x41c>
				return;
			putch(ch, putdat);
  800910:	89 74 24 04          	mov    %esi,0x4(%esp)
  800914:	89 04 24             	mov    %eax,(%esp)
  800917:	ff d7                	call   *%edi
	unsigned long long num;
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
  800919:	0f b6 03             	movzbl (%ebx),%eax
  80091c:	83 c3 01             	add    $0x1,%ebx
  80091f:	83 f8 25             	cmp    $0x25,%eax
  800922:	75 e4                	jne    800908 <vprintfmt+0x1b>
  800924:	c6 45 d4 20          	movb   $0x20,-0x2c(%ebp)
  800928:	c7 45 d8 00 00 00 00 	movl   $0x0,-0x28(%ebp)
  80092f:	c7 45 d0 ff ff ff ff 	movl   $0xffffffff,-0x30(%ebp)
  800936:	c7 45 e4 ff ff ff ff 	movl   $0xffffffff,-0x1c(%ebp)
  80093d:	b9 00 00 00 00       	mov    $0x0,%ecx
  800942:	eb 06                	jmp    80094a <vprintfmt+0x5d>
  800944:	c6 45 d4 2d          	movb   $0x2d,-0x2c(%ebp)
  800948:	89 c3                	mov    %eax,%ebx
		width = -1;
		precision = -1;
		lflag = 0;
		altflag = 0;
	reswitch:
		switch (ch = *(unsigned char *) fmt++) {
  80094a:	0f b6 13             	movzbl (%ebx),%edx
  80094d:	0f b6 c2             	movzbl %dl,%eax
  800950:	89 45 e0             	mov    %eax,-0x20(%ebp)
  800953:	8d 43 01             	lea    0x1(%ebx),%eax
  800956:	83 ea 23             	sub    $0x23,%edx
  800959:	80 fa 55             	cmp    $0x55,%dl
  80095c:	0f 87 8a 03 00 00    	ja     800cec <vprintfmt+0x3ff>
  800962:	0f b6 d2             	movzbl %dl,%edx
  800965:	ff 24 95 80 38 80 00 	jmp    *0x803880(,%edx,4)
  80096c:	c6 45 d4 30          	movb   $0x30,-0x2c(%ebp)
  800970:	eb d6                	jmp    800948 <vprintfmt+0x5b>
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
				precision = precision * 10 + ch - '0';
  800972:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800975:	83 ea 30             	sub    $0x30,%edx
  800978:	89 55 d0             	mov    %edx,-0x30(%ebp)
				ch = *fmt;
  80097b:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  80097e:	8d 5a d0             	lea    -0x30(%edx),%ebx
  800981:	83 fb 09             	cmp    $0x9,%ebx
  800984:	77 54                	ja     8009da <vprintfmt+0xed>
  800986:	89 4d e0             	mov    %ecx,-0x20(%ebp)
  800989:	8b 4d d0             	mov    -0x30(%ebp),%ecx
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
  80098c:	83 c0 01             	add    $0x1,%eax
				precision = precision * 10 + ch - '0';
  80098f:	8d 0c 89             	lea    (%ecx,%ecx,4),%ecx
  800992:	8d 4c 4a d0          	lea    -0x30(%edx,%ecx,2),%ecx
				ch = *fmt;
  800996:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  800999:	8d 5a d0             	lea    -0x30(%edx),%ebx
  80099c:	83 fb 09             	cmp    $0x9,%ebx
  80099f:	76 eb                	jbe    80098c <vprintfmt+0x9f>
  8009a1:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  8009a4:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  8009a7:	eb 31                	jmp    8009da <vprintfmt+0xed>
					break;
			}
			goto process_precision;

		case '*':
			precision = va_arg(ap, int);
  8009a9:	8b 55 14             	mov    0x14(%ebp),%edx
  8009ac:	8d 5a 04             	lea    0x4(%edx),%ebx
  8009af:	89 5d 14             	mov    %ebx,0x14(%ebp)
  8009b2:	8b 12                	mov    (%edx),%edx
  8009b4:	89 55 d0             	mov    %edx,-0x30(%ebp)
			goto process_precision;
  8009b7:	eb 21                	jmp    8009da <vprintfmt+0xed>

		case '.':
			if (width < 0)
  8009b9:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  8009bd:	ba 00 00 00 00       	mov    $0x0,%edx
  8009c2:	0f 49 55 e4          	cmovns -0x1c(%ebp),%edx
  8009c6:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8009c9:	e9 7a ff ff ff       	jmp    800948 <vprintfmt+0x5b>
  8009ce:	c7 45 d8 01 00 00 00 	movl   $0x1,-0x28(%ebp)
				width = 0;
			goto reswitch;

		case '#':
			altflag = 1;
			goto reswitch;
  8009d5:	e9 6e ff ff ff       	jmp    800948 <vprintfmt+0x5b>

		process_precision:
			if (width < 0)
  8009da:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  8009de:	0f 89 64 ff ff ff    	jns    800948 <vprintfmt+0x5b>
  8009e4:	8b 55 d0             	mov    -0x30(%ebp),%edx
  8009e7:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8009ea:	8b 55 c8             	mov    -0x38(%ebp),%edx
  8009ed:	89 55 d0             	mov    %edx,-0x30(%ebp)
  8009f0:	e9 53 ff ff ff       	jmp    800948 <vprintfmt+0x5b>
				width = precision, precision = -1;
			goto reswitch;

		// long flag (doubled for long long)
		case 'l':
			lflag++;
  8009f5:	83 c1 01             	add    $0x1,%ecx
			goto reswitch;
  8009f8:	e9 4b ff ff ff       	jmp    800948 <vprintfmt+0x5b>
  8009fd:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// character
		case 'c':
			putch(va_arg(ap, int), putdat);
  800a00:	8b 45 14             	mov    0x14(%ebp),%eax
  800a03:	8d 50 04             	lea    0x4(%eax),%edx
  800a06:	89 55 14             	mov    %edx,0x14(%ebp)
  800a09:	89 74 24 04          	mov    %esi,0x4(%esp)
  800a0d:	8b 00                	mov    (%eax),%eax
  800a0f:	89 04 24             	mov    %eax,(%esp)
  800a12:	ff d7                	call   *%edi
  800a14:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800a17:	e9 fd fe ff ff       	jmp    800919 <vprintfmt+0x2c>
  800a1c:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// error message
		case 'e':
			err = va_arg(ap, int);
  800a1f:	8b 45 14             	mov    0x14(%ebp),%eax
  800a22:	8d 50 04             	lea    0x4(%eax),%edx
  800a25:	89 55 14             	mov    %edx,0x14(%ebp)
  800a28:	8b 00                	mov    (%eax),%eax
  800a2a:	89 c2                	mov    %eax,%edx
  800a2c:	c1 fa 1f             	sar    $0x1f,%edx
  800a2f:	31 d0                	xor    %edx,%eax
  800a31:	29 d0                	sub    %edx,%eax
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  800a33:	83 f8 12             	cmp    $0x12,%eax
  800a36:	7f 0b                	jg     800a43 <vprintfmt+0x156>
  800a38:	8b 14 85 e0 39 80 00 	mov    0x8039e0(,%eax,4),%edx
  800a3f:	85 d2                	test   %edx,%edx
  800a41:	75 20                	jne    800a63 <vprintfmt+0x176>
				printfmt(putch, putdat, "error %d", err);
  800a43:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800a47:	c7 44 24 08 4e 37 80 	movl   $0x80374e,0x8(%esp)
  800a4e:	00 
  800a4f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800a53:	89 3c 24             	mov    %edi,(%esp)
  800a56:	e8 36 03 00 00       	call   800d91 <printfmt>
  800a5b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
		// error message
		case 'e':
			err = va_arg(ap, int);
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  800a5e:	e9 b6 fe ff ff       	jmp    800919 <vprintfmt+0x2c>
				printfmt(putch, putdat, "error %d", err);
			else
				printfmt(putch, putdat, "%s", p);
  800a63:	89 54 24 0c          	mov    %edx,0xc(%esp)
  800a67:	c7 44 24 08 22 3d 80 	movl   $0x803d22,0x8(%esp)
  800a6e:	00 
  800a6f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800a73:	89 3c 24             	mov    %edi,(%esp)
  800a76:	e8 16 03 00 00       	call   800d91 <printfmt>
  800a7b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  800a7e:	e9 96 fe ff ff       	jmp    800919 <vprintfmt+0x2c>
  800a83:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800a86:	89 c3                	mov    %eax,%ebx
  800a88:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  800a8b:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  800a8e:	89 45 c4             	mov    %eax,-0x3c(%ebp)
			break;

		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
  800a91:	8b 45 14             	mov    0x14(%ebp),%eax
  800a94:	8d 50 04             	lea    0x4(%eax),%edx
  800a97:	89 55 14             	mov    %edx,0x14(%ebp)
  800a9a:	8b 00                	mov    (%eax),%eax
  800a9c:	89 45 e0             	mov    %eax,-0x20(%ebp)
  800a9f:	85 c0                	test   %eax,%eax
  800aa1:	b8 57 37 80 00       	mov    $0x803757,%eax
  800aa6:	0f 45 45 e0          	cmovne -0x20(%ebp),%eax
  800aaa:	89 45 e0             	mov    %eax,-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
  800aad:	83 7d c4 00          	cmpl   $0x0,-0x3c(%ebp)
  800ab1:	7e 06                	jle    800ab9 <vprintfmt+0x1cc>
  800ab3:	80 7d d4 2d          	cmpb   $0x2d,-0x2c(%ebp)
  800ab7:	75 13                	jne    800acc <vprintfmt+0x1df>
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800ab9:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800abc:	0f be 02             	movsbl (%edx),%eax
  800abf:	85 c0                	test   %eax,%eax
  800ac1:	0f 85 9b 00 00 00    	jne    800b62 <vprintfmt+0x275>
  800ac7:	e9 88 00 00 00       	jmp    800b54 <vprintfmt+0x267>
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  800acc:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800ad0:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800ad3:	89 0c 24             	mov    %ecx,(%esp)
  800ad6:	e8 00 03 00 00       	call   800ddb <strnlen>
  800adb:	8b 55 c4             	mov    -0x3c(%ebp),%edx
  800ade:	29 c2                	sub    %eax,%edx
  800ae0:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  800ae3:	85 d2                	test   %edx,%edx
  800ae5:	7e d2                	jle    800ab9 <vprintfmt+0x1cc>
					putch(padc, putdat);
  800ae7:	0f be 4d d4          	movsbl -0x2c(%ebp),%ecx
  800aeb:	89 4d d4             	mov    %ecx,-0x2c(%ebp)
  800aee:	89 5d c4             	mov    %ebx,-0x3c(%ebp)
  800af1:	89 d3                	mov    %edx,%ebx
  800af3:	89 74 24 04          	mov    %esi,0x4(%esp)
  800af7:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  800afa:	89 04 24             	mov    %eax,(%esp)
  800afd:	ff d7                	call   *%edi
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  800aff:	83 eb 01             	sub    $0x1,%ebx
  800b02:	85 db                	test   %ebx,%ebx
  800b04:	7f ed                	jg     800af3 <vprintfmt+0x206>
  800b06:	8b 5d c4             	mov    -0x3c(%ebp),%ebx
  800b09:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  800b10:	eb a7                	jmp    800ab9 <vprintfmt+0x1cc>
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  800b12:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  800b16:	74 1a                	je     800b32 <vprintfmt+0x245>
  800b18:	8d 50 e0             	lea    -0x20(%eax),%edx
  800b1b:	83 fa 5e             	cmp    $0x5e,%edx
  800b1e:	76 12                	jbe    800b32 <vprintfmt+0x245>
					putch('?', putdat);
  800b20:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800b24:	c7 04 24 3f 00 00 00 	movl   $0x3f,(%esp)
  800b2b:	ff 55 e0             	call   *-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  800b2e:	66 90                	xchg   %ax,%ax
  800b30:	eb 0a                	jmp    800b3c <vprintfmt+0x24f>
					putch('?', putdat);
				else
					putch(ch, putdat);
  800b32:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800b36:	89 04 24             	mov    %eax,(%esp)
  800b39:	ff 55 e0             	call   *-0x20(%ebp)
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800b3c:	83 6d e4 01          	subl   $0x1,-0x1c(%ebp)
  800b40:	0f be 03             	movsbl (%ebx),%eax
  800b43:	85 c0                	test   %eax,%eax
  800b45:	74 05                	je     800b4c <vprintfmt+0x25f>
  800b47:	83 c3 01             	add    $0x1,%ebx
  800b4a:	eb 29                	jmp    800b75 <vprintfmt+0x288>
  800b4c:	89 fe                	mov    %edi,%esi
  800b4e:	8b 7d e0             	mov    -0x20(%ebp),%edi
  800b51:	8b 5d d0             	mov    -0x30(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  800b54:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  800b58:	7f 2e                	jg     800b88 <vprintfmt+0x29b>
  800b5a:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  800b5d:	e9 b7 fd ff ff       	jmp    800919 <vprintfmt+0x2c>
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800b62:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800b65:	83 c2 01             	add    $0x1,%edx
  800b68:	89 7d e0             	mov    %edi,-0x20(%ebp)
  800b6b:	89 f7                	mov    %esi,%edi
  800b6d:	8b 75 d0             	mov    -0x30(%ebp),%esi
  800b70:	89 5d d0             	mov    %ebx,-0x30(%ebp)
  800b73:	89 d3                	mov    %edx,%ebx
  800b75:	85 f6                	test   %esi,%esi
  800b77:	78 99                	js     800b12 <vprintfmt+0x225>
  800b79:	83 ee 01             	sub    $0x1,%esi
  800b7c:	79 94                	jns    800b12 <vprintfmt+0x225>
  800b7e:	89 fe                	mov    %edi,%esi
  800b80:	8b 7d e0             	mov    -0x20(%ebp),%edi
  800b83:	8b 5d d0             	mov    -0x30(%ebp),%ebx
  800b86:	eb cc                	jmp    800b54 <vprintfmt+0x267>
  800b88:	89 5d d8             	mov    %ebx,-0x28(%ebp)
  800b8b:	8b 5d e4             	mov    -0x1c(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
				putch(' ', putdat);
  800b8e:	89 74 24 04          	mov    %esi,0x4(%esp)
  800b92:	c7 04 24 20 00 00 00 	movl   $0x20,(%esp)
  800b99:	ff d7                	call   *%edi
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  800b9b:	83 eb 01             	sub    $0x1,%ebx
  800b9e:	85 db                	test   %ebx,%ebx
  800ba0:	7f ec                	jg     800b8e <vprintfmt+0x2a1>
  800ba2:	8b 5d d8             	mov    -0x28(%ebp),%ebx
  800ba5:	e9 6f fd ff ff       	jmp    800919 <vprintfmt+0x2c>
  800baa:	89 45 cc             	mov    %eax,-0x34(%ebp)
// Same as getuint but signed - can't use getuint
// because of sign extension
static long long
getint(va_list *ap, int lflag)
{
	if (lflag >= 2)
  800bad:	83 f9 01             	cmp    $0x1,%ecx
  800bb0:	7e 16                	jle    800bc8 <vprintfmt+0x2db>
		return va_arg(*ap, long long);
  800bb2:	8b 45 14             	mov    0x14(%ebp),%eax
  800bb5:	8d 50 08             	lea    0x8(%eax),%edx
  800bb8:	89 55 14             	mov    %edx,0x14(%ebp)
  800bbb:	8b 10                	mov    (%eax),%edx
  800bbd:	8b 48 04             	mov    0x4(%eax),%ecx
  800bc0:	89 55 d8             	mov    %edx,-0x28(%ebp)
  800bc3:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800bc6:	eb 32                	jmp    800bfa <vprintfmt+0x30d>
	else if (lflag)
  800bc8:	85 c9                	test   %ecx,%ecx
  800bca:	74 18                	je     800be4 <vprintfmt+0x2f7>
		return va_arg(*ap, long);
  800bcc:	8b 45 14             	mov    0x14(%ebp),%eax
  800bcf:	8d 50 04             	lea    0x4(%eax),%edx
  800bd2:	89 55 14             	mov    %edx,0x14(%ebp)
  800bd5:	8b 00                	mov    (%eax),%eax
  800bd7:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800bda:	89 c1                	mov    %eax,%ecx
  800bdc:	c1 f9 1f             	sar    $0x1f,%ecx
  800bdf:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800be2:	eb 16                	jmp    800bfa <vprintfmt+0x30d>
	else
		return va_arg(*ap, int);
  800be4:	8b 45 14             	mov    0x14(%ebp),%eax
  800be7:	8d 50 04             	lea    0x4(%eax),%edx
  800bea:	89 55 14             	mov    %edx,0x14(%ebp)
  800bed:	8b 00                	mov    (%eax),%eax
  800bef:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800bf2:	89 c2                	mov    %eax,%edx
  800bf4:	c1 fa 1f             	sar    $0x1f,%edx
  800bf7:	89 55 dc             	mov    %edx,-0x24(%ebp)
				putch(' ', putdat);
			break;

		// (signed) decimal
		case 'd':
			num = getint(&ap, lflag);
  800bfa:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  800bfd:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800c00:	b8 0a 00 00 00       	mov    $0xa,%eax
			if ((long long) num < 0) {
  800c05:	83 7d dc 00          	cmpl   $0x0,-0x24(%ebp)
  800c09:	0f 89 9b 00 00 00    	jns    800caa <vprintfmt+0x3bd>
				putch('-', putdat);
  800c0f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800c13:	c7 04 24 2d 00 00 00 	movl   $0x2d,(%esp)
  800c1a:	ff d7                	call   *%edi
				num = -(long long) num;
  800c1c:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  800c1f:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800c22:	f7 d9                	neg    %ecx
  800c24:	83 d3 00             	adc    $0x0,%ebx
  800c27:	f7 db                	neg    %ebx
  800c29:	b8 0a 00 00 00       	mov    $0xa,%eax
  800c2e:	eb 7a                	jmp    800caa <vprintfmt+0x3bd>
  800c30:	89 45 cc             	mov    %eax,-0x34(%ebp)
			base = 10;
			goto number;

		// unsigned decimal
		case 'u':
			num = getuint(&ap, lflag);
  800c33:	89 ca                	mov    %ecx,%edx
  800c35:	8d 45 14             	lea    0x14(%ebp),%eax
  800c38:	e8 59 fc ff ff       	call   800896 <getuint>
  800c3d:	89 c1                	mov    %eax,%ecx
  800c3f:	89 d3                	mov    %edx,%ebx
  800c41:	b8 0a 00 00 00       	mov    $0xa,%eax
			base = 10;
			goto number;
  800c46:	eb 62                	jmp    800caa <vprintfmt+0x3bd>
  800c48:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) octal
		case 'o':
			num = getuint(&ap, lflag);
  800c4b:	89 ca                	mov    %ecx,%edx
  800c4d:	8d 45 14             	lea    0x14(%ebp),%eax
  800c50:	e8 41 fc ff ff       	call   800896 <getuint>
  800c55:	89 c1                	mov    %eax,%ecx
  800c57:	89 d3                	mov    %edx,%ebx
  800c59:	b8 08 00 00 00       	mov    $0x8,%eax
			base = 8;
			goto number;
  800c5e:	eb 4a                	jmp    800caa <vprintfmt+0x3bd>
  800c60:	89 45 cc             	mov    %eax,-0x34(%ebp)
			break;
			**/

		// pointer
		case 'p':
			putch('0', putdat);
  800c63:	89 74 24 04          	mov    %esi,0x4(%esp)
  800c67:	c7 04 24 30 00 00 00 	movl   $0x30,(%esp)
  800c6e:	ff d7                	call   *%edi
			putch('x', putdat);
  800c70:	89 74 24 04          	mov    %esi,0x4(%esp)
  800c74:	c7 04 24 78 00 00 00 	movl   $0x78,(%esp)
  800c7b:	ff d7                	call   *%edi
			num = (unsigned long long)
  800c7d:	8b 45 14             	mov    0x14(%ebp),%eax
  800c80:	8d 50 04             	lea    0x4(%eax),%edx
  800c83:	89 55 14             	mov    %edx,0x14(%ebp)
  800c86:	8b 08                	mov    (%eax),%ecx
  800c88:	bb 00 00 00 00       	mov    $0x0,%ebx
  800c8d:	b8 10 00 00 00       	mov    $0x10,%eax
				(uintptr_t) va_arg(ap, void *);
			base = 16;
			goto number;
  800c92:	eb 16                	jmp    800caa <vprintfmt+0x3bd>
  800c94:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) hexadecimal
		case 'x':
			num = getuint(&ap, lflag);
  800c97:	89 ca                	mov    %ecx,%edx
  800c99:	8d 45 14             	lea    0x14(%ebp),%eax
  800c9c:	e8 f5 fb ff ff       	call   800896 <getuint>
  800ca1:	89 c1                	mov    %eax,%ecx
  800ca3:	89 d3                	mov    %edx,%ebx
  800ca5:	b8 10 00 00 00       	mov    $0x10,%eax
			base = 16;
		number:
			printnum(putch, putdat, num, base, width, padc);
  800caa:	0f be 55 d4          	movsbl -0x2c(%ebp),%edx
  800cae:	89 54 24 10          	mov    %edx,0x10(%esp)
  800cb2:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  800cb5:	89 54 24 0c          	mov    %edx,0xc(%esp)
  800cb9:	89 44 24 08          	mov    %eax,0x8(%esp)
  800cbd:	89 0c 24             	mov    %ecx,(%esp)
  800cc0:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800cc4:	89 f2                	mov    %esi,%edx
  800cc6:	89 f8                	mov    %edi,%eax
  800cc8:	e8 d3 fa ff ff       	call   8007a0 <printnum>
  800ccd:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800cd0:	e9 44 fc ff ff       	jmp    800919 <vprintfmt+0x2c>
  800cd5:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800cd8:	8b 55 e0             	mov    -0x20(%ebp),%edx

		// escaped '%' character
		case '%':
			putch(ch, putdat);
  800cdb:	89 74 24 04          	mov    %esi,0x4(%esp)
  800cdf:	89 14 24             	mov    %edx,(%esp)
  800ce2:	ff d7                	call   *%edi
  800ce4:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800ce7:	e9 2d fc ff ff       	jmp    800919 <vprintfmt+0x2c>
			
		// unrecognized escape sequence - just print it literally
		default:
			putch('%', putdat);
  800cec:	89 74 24 04          	mov    %esi,0x4(%esp)
  800cf0:	c7 04 24 25 00 00 00 	movl   $0x25,(%esp)
  800cf7:	ff d7                	call   *%edi
			for (fmt--; fmt[-1] != '%'; fmt--)
  800cf9:	8d 43 ff             	lea    -0x1(%ebx),%eax
  800cfc:	80 38 25             	cmpb   $0x25,(%eax)
  800cff:	0f 84 14 fc ff ff    	je     800919 <vprintfmt+0x2c>
  800d05:	89 c3                	mov    %eax,%ebx
  800d07:	eb f0                	jmp    800cf9 <vprintfmt+0x40c>
				/* do nothing */;
			break;
		}
	}
}
  800d09:	83 c4 5c             	add    $0x5c,%esp
  800d0c:	5b                   	pop    %ebx
  800d0d:	5e                   	pop    %esi
  800d0e:	5f                   	pop    %edi
  800d0f:	5d                   	pop    %ebp
  800d10:	c3                   	ret    

00800d11 <vsnprintf>:
		*b->buf++ = ch;
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
  800d11:	55                   	push   %ebp
  800d12:	89 e5                	mov    %esp,%ebp
  800d14:	83 ec 28             	sub    $0x28,%esp
  800d17:	8b 45 08             	mov    0x8(%ebp),%eax
  800d1a:	8b 55 0c             	mov    0xc(%ebp),%edx
	struct sprintbuf b = {buf, buf+n-1, 0};

	if (buf == NULL || n < 1)
  800d1d:	85 c0                	test   %eax,%eax
  800d1f:	74 04                	je     800d25 <vsnprintf+0x14>
  800d21:	85 d2                	test   %edx,%edx
  800d23:	7f 07                	jg     800d2c <vsnprintf+0x1b>
  800d25:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  800d2a:	eb 3b                	jmp    800d67 <vsnprintf+0x56>
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
	struct sprintbuf b = {buf, buf+n-1, 0};
  800d2c:	89 45 ec             	mov    %eax,-0x14(%ebp)
  800d2f:	8d 44 10 ff          	lea    -0x1(%eax,%edx,1),%eax
  800d33:	89 45 f0             	mov    %eax,-0x10(%ebp)
  800d36:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	if (buf == NULL || n < 1)
		return -E_INVAL;

	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  800d3d:	8b 45 14             	mov    0x14(%ebp),%eax
  800d40:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800d44:	8b 45 10             	mov    0x10(%ebp),%eax
  800d47:	89 44 24 08          	mov    %eax,0x8(%esp)
  800d4b:	8d 45 ec             	lea    -0x14(%ebp),%eax
  800d4e:	89 44 24 04          	mov    %eax,0x4(%esp)
  800d52:	c7 04 24 d0 08 80 00 	movl   $0x8008d0,(%esp)
  800d59:	e8 8f fb ff ff       	call   8008ed <vprintfmt>

	// null terminate the buffer
	*b.buf = '\0';
  800d5e:	8b 45 ec             	mov    -0x14(%ebp),%eax
  800d61:	c6 00 00             	movb   $0x0,(%eax)

	return b.cnt;
  800d64:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  800d67:	c9                   	leave  
  800d68:	c3                   	ret    

00800d69 <snprintf>:

int
snprintf(char *buf, int n, const char *fmt, ...)
{
  800d69:	55                   	push   %ebp
  800d6a:	89 e5                	mov    %esp,%ebp
  800d6c:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
snprintf(char *buf, int n, const char *fmt, ...)
  800d6f:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;
	int rc;

	va_start(ap, fmt);
	rc = vsnprintf(buf, n, fmt, ap);
  800d72:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800d76:	8b 45 10             	mov    0x10(%ebp),%eax
  800d79:	89 44 24 08          	mov    %eax,0x8(%esp)
  800d7d:	8b 45 0c             	mov    0xc(%ebp),%eax
  800d80:	89 44 24 04          	mov    %eax,0x4(%esp)
  800d84:	8b 45 08             	mov    0x8(%ebp),%eax
  800d87:	89 04 24             	mov    %eax,(%esp)
  800d8a:	e8 82 ff ff ff       	call   800d11 <vsnprintf>
	va_end(ap);

	return rc;
}
  800d8f:	c9                   	leave  
  800d90:	c3                   	ret    

00800d91 <printfmt>:
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
{
  800d91:	55                   	push   %ebp
  800d92:	89 e5                	mov    %esp,%ebp
  800d94:	83 ec 18             	sub    $0x18,%esp
		}
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
  800d97:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;

	va_start(ap, fmt);
	vprintfmt(putch, putdat, fmt, ap);
  800d9a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800d9e:	8b 45 10             	mov    0x10(%ebp),%eax
  800da1:	89 44 24 08          	mov    %eax,0x8(%esp)
  800da5:	8b 45 0c             	mov    0xc(%ebp),%eax
  800da8:	89 44 24 04          	mov    %eax,0x4(%esp)
  800dac:	8b 45 08             	mov    0x8(%ebp),%eax
  800daf:	89 04 24             	mov    %eax,(%esp)
  800db2:	e8 36 fb ff ff       	call   8008ed <vprintfmt>
	va_end(ap);
}
  800db7:	c9                   	leave  
  800db8:	c3                   	ret    
  800db9:	00 00                	add    %al,(%eax)
  800dbb:	00 00                	add    %al,(%eax)
  800dbd:	00 00                	add    %al,(%eax)
	...

00800dc0 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1

int
strlen(const char *s)
{
  800dc0:	55                   	push   %ebp
  800dc1:	89 e5                	mov    %esp,%ebp
  800dc3:	8b 55 08             	mov    0x8(%ebp),%edx
	int n;

	for (n = 0; *s != '\0'; s++)
  800dc6:	b8 00 00 00 00       	mov    $0x0,%eax
  800dcb:	80 3a 00             	cmpb   $0x0,(%edx)
  800dce:	74 09                	je     800dd9 <strlen+0x19>
		n++;
  800dd0:	83 c0 01             	add    $0x1,%eax
int
strlen(const char *s)
{
	int n;

	for (n = 0; *s != '\0'; s++)
  800dd3:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  800dd7:	75 f7                	jne    800dd0 <strlen+0x10>
		n++;
	return n;
}
  800dd9:	5d                   	pop    %ebp
  800dda:	c3                   	ret    

00800ddb <strnlen>:

int
strnlen(const char *s, size_t size)
{
  800ddb:	55                   	push   %ebp
  800ddc:	89 e5                	mov    %esp,%ebp
  800dde:	53                   	push   %ebx
  800ddf:	8b 5d 08             	mov    0x8(%ebp),%ebx
  800de2:	8b 4d 0c             	mov    0xc(%ebp),%ecx
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800de5:	85 c9                	test   %ecx,%ecx
  800de7:	74 19                	je     800e02 <strnlen+0x27>
  800de9:	80 3b 00             	cmpb   $0x0,(%ebx)
  800dec:	74 14                	je     800e02 <strnlen+0x27>
  800dee:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
  800df3:	83 c0 01             	add    $0x1,%eax
int
strnlen(const char *s, size_t size)
{
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800df6:	39 c8                	cmp    %ecx,%eax
  800df8:	74 0d                	je     800e07 <strnlen+0x2c>
  800dfa:	80 3c 03 00          	cmpb   $0x0,(%ebx,%eax,1)
  800dfe:	75 f3                	jne    800df3 <strnlen+0x18>
  800e00:	eb 05                	jmp    800e07 <strnlen+0x2c>
  800e02:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
	return n;
}
  800e07:	5b                   	pop    %ebx
  800e08:	5d                   	pop    %ebp
  800e09:	c3                   	ret    

00800e0a <strcpy>:

char *
strcpy(char *dst, const char *src)
{
  800e0a:	55                   	push   %ebp
  800e0b:	89 e5                	mov    %esp,%ebp
  800e0d:	53                   	push   %ebx
  800e0e:	8b 45 08             	mov    0x8(%ebp),%eax
  800e11:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800e14:	ba 00 00 00 00       	mov    $0x0,%edx
	char *ret;

	ret = dst;
	while ((*dst++ = *src++) != '\0')
  800e19:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
  800e1d:	88 0c 10             	mov    %cl,(%eax,%edx,1)
  800e20:	83 c2 01             	add    $0x1,%edx
  800e23:	84 c9                	test   %cl,%cl
  800e25:	75 f2                	jne    800e19 <strcpy+0xf>
		/* do nothing */;
	return ret;
}
  800e27:	5b                   	pop    %ebx
  800e28:	5d                   	pop    %ebp
  800e29:	c3                   	ret    

00800e2a <strncpy>:

char *
strncpy(char *dst, const char *src, size_t size) {
  800e2a:	55                   	push   %ebp
  800e2b:	89 e5                	mov    %esp,%ebp
  800e2d:	56                   	push   %esi
  800e2e:	53                   	push   %ebx
  800e2f:	8b 45 08             	mov    0x8(%ebp),%eax
  800e32:	8b 55 0c             	mov    0xc(%ebp),%edx
  800e35:	8b 75 10             	mov    0x10(%ebp),%esi
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  800e38:	85 f6                	test   %esi,%esi
  800e3a:	74 18                	je     800e54 <strncpy+0x2a>
  800e3c:	b9 00 00 00 00       	mov    $0x0,%ecx
		*dst++ = *src;
  800e41:	0f b6 1a             	movzbl (%edx),%ebx
  800e44:	88 1c 08             	mov    %bl,(%eax,%ecx,1)
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
  800e47:	80 3a 01             	cmpb   $0x1,(%edx)
  800e4a:	83 da ff             	sbb    $0xffffffff,%edx
strncpy(char *dst, const char *src, size_t size) {
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  800e4d:	83 c1 01             	add    $0x1,%ecx
  800e50:	39 ce                	cmp    %ecx,%esi
  800e52:	77 ed                	ja     800e41 <strncpy+0x17>
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
	}
	return ret;
}
  800e54:	5b                   	pop    %ebx
  800e55:	5e                   	pop    %esi
  800e56:	5d                   	pop    %ebp
  800e57:	c3                   	ret    

00800e58 <strlcpy>:

size_t
strlcpy(char *dst, const char *src, size_t size)
{
  800e58:	55                   	push   %ebp
  800e59:	89 e5                	mov    %esp,%ebp
  800e5b:	56                   	push   %esi
  800e5c:	53                   	push   %ebx
  800e5d:	8b 75 08             	mov    0x8(%ebp),%esi
  800e60:	8b 55 0c             	mov    0xc(%ebp),%edx
  800e63:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
  800e66:	89 f0                	mov    %esi,%eax
  800e68:	85 c9                	test   %ecx,%ecx
  800e6a:	74 27                	je     800e93 <strlcpy+0x3b>
		while (--size > 0 && *src != '\0')
  800e6c:	83 e9 01             	sub    $0x1,%ecx
  800e6f:	74 1d                	je     800e8e <strlcpy+0x36>
  800e71:	0f b6 1a             	movzbl (%edx),%ebx
  800e74:	84 db                	test   %bl,%bl
  800e76:	74 16                	je     800e8e <strlcpy+0x36>
			*dst++ = *src++;
  800e78:	88 18                	mov    %bl,(%eax)
  800e7a:	83 c0 01             	add    $0x1,%eax
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800e7d:	83 e9 01             	sub    $0x1,%ecx
  800e80:	74 0e                	je     800e90 <strlcpy+0x38>
			*dst++ = *src++;
  800e82:	83 c2 01             	add    $0x1,%edx
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800e85:	0f b6 1a             	movzbl (%edx),%ebx
  800e88:	84 db                	test   %bl,%bl
  800e8a:	75 ec                	jne    800e78 <strlcpy+0x20>
  800e8c:	eb 02                	jmp    800e90 <strlcpy+0x38>
  800e8e:	89 f0                	mov    %esi,%eax
			*dst++ = *src++;
		*dst = '\0';
  800e90:	c6 00 00             	movb   $0x0,(%eax)
  800e93:	29 f0                	sub    %esi,%eax
	}
	return dst - dst_in;
}
  800e95:	5b                   	pop    %ebx
  800e96:	5e                   	pop    %esi
  800e97:	5d                   	pop    %ebp
  800e98:	c3                   	ret    

00800e99 <strcmp>:

int
strcmp(const char *p, const char *q)
{
  800e99:	55                   	push   %ebp
  800e9a:	89 e5                	mov    %esp,%ebp
  800e9c:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800e9f:	8b 55 0c             	mov    0xc(%ebp),%edx
	while (*p && *p == *q)
  800ea2:	0f b6 01             	movzbl (%ecx),%eax
  800ea5:	84 c0                	test   %al,%al
  800ea7:	74 15                	je     800ebe <strcmp+0x25>
  800ea9:	3a 02                	cmp    (%edx),%al
  800eab:	75 11                	jne    800ebe <strcmp+0x25>
		p++, q++;
  800ead:	83 c1 01             	add    $0x1,%ecx
  800eb0:	83 c2 01             	add    $0x1,%edx
}

int
strcmp(const char *p, const char *q)
{
	while (*p && *p == *q)
  800eb3:	0f b6 01             	movzbl (%ecx),%eax
  800eb6:	84 c0                	test   %al,%al
  800eb8:	74 04                	je     800ebe <strcmp+0x25>
  800eba:	3a 02                	cmp    (%edx),%al
  800ebc:	74 ef                	je     800ead <strcmp+0x14>
  800ebe:	0f b6 c0             	movzbl %al,%eax
  800ec1:	0f b6 12             	movzbl (%edx),%edx
  800ec4:	29 d0                	sub    %edx,%eax
		p++, q++;
	return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800ec6:	5d                   	pop    %ebp
  800ec7:	c3                   	ret    

00800ec8 <strncmp>:

int
strncmp(const char *p, const char *q, size_t n)
{
  800ec8:	55                   	push   %ebp
  800ec9:	89 e5                	mov    %esp,%ebp
  800ecb:	53                   	push   %ebx
  800ecc:	8b 55 08             	mov    0x8(%ebp),%edx
  800ecf:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800ed2:	8b 45 10             	mov    0x10(%ebp),%eax
	while (n > 0 && *p && *p == *q)
  800ed5:	85 c0                	test   %eax,%eax
  800ed7:	74 23                	je     800efc <strncmp+0x34>
  800ed9:	0f b6 1a             	movzbl (%edx),%ebx
  800edc:	84 db                	test   %bl,%bl
  800ede:	74 24                	je     800f04 <strncmp+0x3c>
  800ee0:	3a 19                	cmp    (%ecx),%bl
  800ee2:	75 20                	jne    800f04 <strncmp+0x3c>
  800ee4:	83 e8 01             	sub    $0x1,%eax
  800ee7:	74 13                	je     800efc <strncmp+0x34>
		n--, p++, q++;
  800ee9:	83 c2 01             	add    $0x1,%edx
  800eec:	83 c1 01             	add    $0x1,%ecx
}

int
strncmp(const char *p, const char *q, size_t n)
{
	while (n > 0 && *p && *p == *q)
  800eef:	0f b6 1a             	movzbl (%edx),%ebx
  800ef2:	84 db                	test   %bl,%bl
  800ef4:	74 0e                	je     800f04 <strncmp+0x3c>
  800ef6:	3a 19                	cmp    (%ecx),%bl
  800ef8:	74 ea                	je     800ee4 <strncmp+0x1c>
  800efa:	eb 08                	jmp    800f04 <strncmp+0x3c>
  800efc:	b8 00 00 00 00       	mov    $0x0,%eax
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800f01:	5b                   	pop    %ebx
  800f02:	5d                   	pop    %ebp
  800f03:	c3                   	ret    
	while (n > 0 && *p && *p == *q)
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
  800f04:	0f b6 02             	movzbl (%edx),%eax
  800f07:	0f b6 11             	movzbl (%ecx),%edx
  800f0a:	29 d0                	sub    %edx,%eax
  800f0c:	eb f3                	jmp    800f01 <strncmp+0x39>

00800f0e <strchr>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
  800f0e:	55                   	push   %ebp
  800f0f:	89 e5                	mov    %esp,%ebp
  800f11:	8b 45 08             	mov    0x8(%ebp),%eax
  800f14:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800f18:	0f b6 10             	movzbl (%eax),%edx
  800f1b:	84 d2                	test   %dl,%dl
  800f1d:	74 15                	je     800f34 <strchr+0x26>
		if (*s == c)
  800f1f:	38 ca                	cmp    %cl,%dl
  800f21:	75 07                	jne    800f2a <strchr+0x1c>
  800f23:	eb 14                	jmp    800f39 <strchr+0x2b>
  800f25:	38 ca                	cmp    %cl,%dl
  800f27:	90                   	nop
  800f28:	74 0f                	je     800f39 <strchr+0x2b>
// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
	for (; *s; s++)
  800f2a:	83 c0 01             	add    $0x1,%eax
  800f2d:	0f b6 10             	movzbl (%eax),%edx
  800f30:	84 d2                	test   %dl,%dl
  800f32:	75 f1                	jne    800f25 <strchr+0x17>
  800f34:	b8 00 00 00 00       	mov    $0x0,%eax
		if (*s == c)
			return (char *) s;
	return 0;
}
  800f39:	5d                   	pop    %ebp
  800f3a:	c3                   	ret    

00800f3b <strfind>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
  800f3b:	55                   	push   %ebp
  800f3c:	89 e5                	mov    %esp,%ebp
  800f3e:	8b 45 08             	mov    0x8(%ebp),%eax
  800f41:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800f45:	0f b6 10             	movzbl (%eax),%edx
  800f48:	84 d2                	test   %dl,%dl
  800f4a:	74 18                	je     800f64 <strfind+0x29>
		if (*s == c)
  800f4c:	38 ca                	cmp    %cl,%dl
  800f4e:	75 0a                	jne    800f5a <strfind+0x1f>
  800f50:	eb 12                	jmp    800f64 <strfind+0x29>
  800f52:	38 ca                	cmp    %cl,%dl
  800f54:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  800f58:	74 0a                	je     800f64 <strfind+0x29>
// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
	for (; *s; s++)
  800f5a:	83 c0 01             	add    $0x1,%eax
  800f5d:	0f b6 10             	movzbl (%eax),%edx
  800f60:	84 d2                	test   %dl,%dl
  800f62:	75 ee                	jne    800f52 <strfind+0x17>
		if (*s == c)
			break;
	return (char *) s;
}
  800f64:	5d                   	pop    %ebp
  800f65:	c3                   	ret    

00800f66 <memset>:

#if ASM
void *
memset(void *v, int c, size_t n)
{
  800f66:	55                   	push   %ebp
  800f67:	89 e5                	mov    %esp,%ebp
  800f69:	83 ec 0c             	sub    $0xc,%esp
  800f6c:	89 1c 24             	mov    %ebx,(%esp)
  800f6f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800f73:	89 7c 24 08          	mov    %edi,0x8(%esp)
  800f77:	8b 7d 08             	mov    0x8(%ebp),%edi
  800f7a:	8b 45 0c             	mov    0xc(%ebp),%eax
  800f7d:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *p;

	if (n == 0)
  800f80:	85 c9                	test   %ecx,%ecx
  800f82:	74 30                	je     800fb4 <memset+0x4e>
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800f84:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800f8a:	75 25                	jne    800fb1 <memset+0x4b>
  800f8c:	f6 c1 03             	test   $0x3,%cl
  800f8f:	75 20                	jne    800fb1 <memset+0x4b>
		c &= 0xFF;
  800f91:	0f b6 d0             	movzbl %al,%edx
		c = (c<<24)|(c<<16)|(c<<8)|c;
  800f94:	89 d3                	mov    %edx,%ebx
  800f96:	c1 e3 08             	shl    $0x8,%ebx
  800f99:	89 d6                	mov    %edx,%esi
  800f9b:	c1 e6 18             	shl    $0x18,%esi
  800f9e:	89 d0                	mov    %edx,%eax
  800fa0:	c1 e0 10             	shl    $0x10,%eax
  800fa3:	09 f0                	or     %esi,%eax
  800fa5:	09 d0                	or     %edx,%eax
		asm volatile("cld; rep stosl\n"
  800fa7:	09 d8                	or     %ebx,%eax
  800fa9:	c1 e9 02             	shr    $0x2,%ecx
  800fac:	fc                   	cld    
  800fad:	f3 ab                	rep stos %eax,%es:(%edi)
{
	char *p;

	if (n == 0)
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800faf:	eb 03                	jmp    800fb4 <memset+0x4e>
		c = (c<<24)|(c<<16)|(c<<8)|c;
		asm volatile("cld; rep stosl\n"
			:: "D" (v), "a" (c), "c" (n/4)
			: "cc", "memory");
	} else
		asm volatile("cld; rep stosb\n"
  800fb1:	fc                   	cld    
  800fb2:	f3 aa                	rep stos %al,%es:(%edi)
			:: "D" (v), "a" (c), "c" (n)
			: "cc", "memory");
	return v;
}
  800fb4:	89 f8                	mov    %edi,%eax
  800fb6:	8b 1c 24             	mov    (%esp),%ebx
  800fb9:	8b 74 24 04          	mov    0x4(%esp),%esi
  800fbd:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800fc1:	89 ec                	mov    %ebp,%esp
  800fc3:	5d                   	pop    %ebp
  800fc4:	c3                   	ret    

00800fc5 <memmove>:

void *
memmove(void *dst, const void *src, size_t n)
{
  800fc5:	55                   	push   %ebp
  800fc6:	89 e5                	mov    %esp,%ebp
  800fc8:	83 ec 08             	sub    $0x8,%esp
  800fcb:	89 34 24             	mov    %esi,(%esp)
  800fce:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800fd2:	8b 45 08             	mov    0x8(%ebp),%eax
  800fd5:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const char *s;
	char *d;
	
	s = src;
  800fd8:	8b 75 0c             	mov    0xc(%ebp),%esi
	d = dst;
  800fdb:	89 c7                	mov    %eax,%edi
	if (s < d && s + n > d) {
  800fdd:	39 c6                	cmp    %eax,%esi
  800fdf:	73 35                	jae    801016 <memmove+0x51>
  800fe1:	8d 14 0e             	lea    (%esi,%ecx,1),%edx
  800fe4:	39 d0                	cmp    %edx,%eax
  800fe6:	73 2e                	jae    801016 <memmove+0x51>
		s += n;
		d += n;
  800fe8:	01 cf                	add    %ecx,%edi
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800fea:	f6 c2 03             	test   $0x3,%dl
  800fed:	75 1b                	jne    80100a <memmove+0x45>
  800fef:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800ff5:	75 13                	jne    80100a <memmove+0x45>
  800ff7:	f6 c1 03             	test   $0x3,%cl
  800ffa:	75 0e                	jne    80100a <memmove+0x45>
			asm volatile("std; rep movsl\n"
  800ffc:	83 ef 04             	sub    $0x4,%edi
  800fff:	8d 72 fc             	lea    -0x4(%edx),%esi
  801002:	c1 e9 02             	shr    $0x2,%ecx
  801005:	fd                   	std    
  801006:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	s = src;
	d = dst;
	if (s < d && s + n > d) {
		s += n;
		d += n;
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  801008:	eb 09                	jmp    801013 <memmove+0x4e>
			asm volatile("std; rep movsl\n"
				:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
		else
			asm volatile("std; rep movsb\n"
  80100a:	83 ef 01             	sub    $0x1,%edi
  80100d:	8d 72 ff             	lea    -0x1(%edx),%esi
  801010:	fd                   	std    
  801011:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
  801013:	fc                   	cld    
	const char *s;
	char *d;
	
	s = src;
	d = dst;
	if (s < d && s + n > d) {
  801014:	eb 20                	jmp    801036 <memmove+0x71>
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  801016:	f7 c6 03 00 00 00    	test   $0x3,%esi
  80101c:	75 15                	jne    801033 <memmove+0x6e>
  80101e:	f7 c7 03 00 00 00    	test   $0x3,%edi
  801024:	75 0d                	jne    801033 <memmove+0x6e>
  801026:	f6 c1 03             	test   $0x3,%cl
  801029:	75 08                	jne    801033 <memmove+0x6e>
			asm volatile("cld; rep movsl\n"
  80102b:	c1 e9 02             	shr    $0x2,%ecx
  80102e:	fc                   	cld    
  80102f:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  801031:	eb 03                	jmp    801036 <memmove+0x71>
			asm volatile("cld; rep movsl\n"
				:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
		else
			asm volatile("cld; rep movsb\n"
  801033:	fc                   	cld    
  801034:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
	}
	return dst;
}
  801036:	8b 34 24             	mov    (%esp),%esi
  801039:	8b 7c 24 04          	mov    0x4(%esp),%edi
  80103d:	89 ec                	mov    %ebp,%esp
  80103f:	5d                   	pop    %ebp
  801040:	c3                   	ret    

00801041 <memcpy>:

/* sigh - gcc emits references to this for structure assignments! */
/* it is *not* prototyped in inc/string.h - do not use directly. */
void *
memcpy(void *dst, void *src, size_t n)
{
  801041:	55                   	push   %ebp
  801042:	89 e5                	mov    %esp,%ebp
  801044:	83 ec 0c             	sub    $0xc,%esp
	return memmove(dst, src, n);
  801047:	8b 45 10             	mov    0x10(%ebp),%eax
  80104a:	89 44 24 08          	mov    %eax,0x8(%esp)
  80104e:	8b 45 0c             	mov    0xc(%ebp),%eax
  801051:	89 44 24 04          	mov    %eax,0x4(%esp)
  801055:	8b 45 08             	mov    0x8(%ebp),%eax
  801058:	89 04 24             	mov    %eax,(%esp)
  80105b:	e8 65 ff ff ff       	call   800fc5 <memmove>
}
  801060:	c9                   	leave  
  801061:	c3                   	ret    

00801062 <memcmp>:

int
memcmp(const void *v1, const void *v2, size_t n)
{
  801062:	55                   	push   %ebp
  801063:	89 e5                	mov    %esp,%ebp
  801065:	57                   	push   %edi
  801066:	56                   	push   %esi
  801067:	53                   	push   %ebx
  801068:	8b 75 08             	mov    0x8(%ebp),%esi
  80106b:	8b 7d 0c             	mov    0xc(%ebp),%edi
  80106e:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  801071:	85 c9                	test   %ecx,%ecx
  801073:	74 36                	je     8010ab <memcmp+0x49>
		if (*s1 != *s2)
  801075:	0f b6 06             	movzbl (%esi),%eax
  801078:	0f b6 1f             	movzbl (%edi),%ebx
  80107b:	38 d8                	cmp    %bl,%al
  80107d:	74 20                	je     80109f <memcmp+0x3d>
  80107f:	eb 14                	jmp    801095 <memcmp+0x33>
  801081:	0f b6 44 16 01       	movzbl 0x1(%esi,%edx,1),%eax
  801086:	0f b6 5c 17 01       	movzbl 0x1(%edi,%edx,1),%ebx
  80108b:	83 c2 01             	add    $0x1,%edx
  80108e:	83 e9 01             	sub    $0x1,%ecx
  801091:	38 d8                	cmp    %bl,%al
  801093:	74 12                	je     8010a7 <memcmp+0x45>
			return (int) *s1 - (int) *s2;
  801095:	0f b6 c0             	movzbl %al,%eax
  801098:	0f b6 db             	movzbl %bl,%ebx
  80109b:	29 d8                	sub    %ebx,%eax
  80109d:	eb 11                	jmp    8010b0 <memcmp+0x4e>
memcmp(const void *v1, const void *v2, size_t n)
{
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  80109f:	83 e9 01             	sub    $0x1,%ecx
  8010a2:	ba 00 00 00 00       	mov    $0x0,%edx
  8010a7:	85 c9                	test   %ecx,%ecx
  8010a9:	75 d6                	jne    801081 <memcmp+0x1f>
  8010ab:	b8 00 00 00 00       	mov    $0x0,%eax
			return (int) *s1 - (int) *s2;
		s1++, s2++;
	}

	return 0;
}
  8010b0:	5b                   	pop    %ebx
  8010b1:	5e                   	pop    %esi
  8010b2:	5f                   	pop    %edi
  8010b3:	5d                   	pop    %ebp
  8010b4:	c3                   	ret    

008010b5 <memfind>:

void *
memfind(const void *s, int c, size_t n)
{
  8010b5:	55                   	push   %ebp
  8010b6:	89 e5                	mov    %esp,%ebp
  8010b8:	8b 45 08             	mov    0x8(%ebp),%eax
	const void *ends = (const char *) s + n;
  8010bb:	89 c2                	mov    %eax,%edx
  8010bd:	03 55 10             	add    0x10(%ebp),%edx
	for (; s < ends; s++)
  8010c0:	39 d0                	cmp    %edx,%eax
  8010c2:	73 15                	jae    8010d9 <memfind+0x24>
		if (*(const unsigned char *) s == (unsigned char) c)
  8010c4:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
  8010c8:	38 08                	cmp    %cl,(%eax)
  8010ca:	75 06                	jne    8010d2 <memfind+0x1d>
  8010cc:	eb 0b                	jmp    8010d9 <memfind+0x24>
  8010ce:	38 08                	cmp    %cl,(%eax)
  8010d0:	74 07                	je     8010d9 <memfind+0x24>

void *
memfind(const void *s, int c, size_t n)
{
	const void *ends = (const char *) s + n;
	for (; s < ends; s++)
  8010d2:	83 c0 01             	add    $0x1,%eax
  8010d5:	39 c2                	cmp    %eax,%edx
  8010d7:	77 f5                	ja     8010ce <memfind+0x19>
		if (*(const unsigned char *) s == (unsigned char) c)
			break;
	return (void *) s;
}
  8010d9:	5d                   	pop    %ebp
  8010da:	c3                   	ret    

008010db <strtol>:

long
strtol(const char *s, char **endptr, int base)
{
  8010db:	55                   	push   %ebp
  8010dc:	89 e5                	mov    %esp,%ebp
  8010de:	57                   	push   %edi
  8010df:	56                   	push   %esi
  8010e0:	53                   	push   %ebx
  8010e1:	83 ec 04             	sub    $0x4,%esp
  8010e4:	8b 55 08             	mov    0x8(%ebp),%edx
  8010e7:	8b 5d 10             	mov    0x10(%ebp),%ebx
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  8010ea:	0f b6 02             	movzbl (%edx),%eax
  8010ed:	3c 20                	cmp    $0x20,%al
  8010ef:	74 04                	je     8010f5 <strtol+0x1a>
  8010f1:	3c 09                	cmp    $0x9,%al
  8010f3:	75 0e                	jne    801103 <strtol+0x28>
		s++;
  8010f5:	83 c2 01             	add    $0x1,%edx
{
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  8010f8:	0f b6 02             	movzbl (%edx),%eax
  8010fb:	3c 20                	cmp    $0x20,%al
  8010fd:	74 f6                	je     8010f5 <strtol+0x1a>
  8010ff:	3c 09                	cmp    $0x9,%al
  801101:	74 f2                	je     8010f5 <strtol+0x1a>
		s++;

	// plus/minus sign
	if (*s == '+')
  801103:	3c 2b                	cmp    $0x2b,%al
  801105:	75 0c                	jne    801113 <strtol+0x38>
		s++;
  801107:	83 c2 01             	add    $0x1,%edx
  80110a:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  801111:	eb 15                	jmp    801128 <strtol+0x4d>
	else if (*s == '-')
  801113:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  80111a:	3c 2d                	cmp    $0x2d,%al
  80111c:	75 0a                	jne    801128 <strtol+0x4d>
		s++, neg = 1;
  80111e:	83 c2 01             	add    $0x1,%edx
  801121:	c7 45 f0 01 00 00 00 	movl   $0x1,-0x10(%ebp)

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  801128:	85 db                	test   %ebx,%ebx
  80112a:	0f 94 c0             	sete   %al
  80112d:	74 05                	je     801134 <strtol+0x59>
  80112f:	83 fb 10             	cmp    $0x10,%ebx
  801132:	75 18                	jne    80114c <strtol+0x71>
  801134:	80 3a 30             	cmpb   $0x30,(%edx)
  801137:	75 13                	jne    80114c <strtol+0x71>
  801139:	80 7a 01 78          	cmpb   $0x78,0x1(%edx)
  80113d:	8d 76 00             	lea    0x0(%esi),%esi
  801140:	75 0a                	jne    80114c <strtol+0x71>
		s += 2, base = 16;
  801142:	83 c2 02             	add    $0x2,%edx
  801145:	bb 10 00 00 00       	mov    $0x10,%ebx
		s++;
	else if (*s == '-')
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  80114a:	eb 15                	jmp    801161 <strtol+0x86>
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  80114c:	84 c0                	test   %al,%al
  80114e:	66 90                	xchg   %ax,%ax
  801150:	74 0f                	je     801161 <strtol+0x86>
  801152:	bb 0a 00 00 00       	mov    $0xa,%ebx
  801157:	80 3a 30             	cmpb   $0x30,(%edx)
  80115a:	75 05                	jne    801161 <strtol+0x86>
		s++, base = 8;
  80115c:	83 c2 01             	add    $0x1,%edx
  80115f:	b3 08                	mov    $0x8,%bl
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  801161:	b8 00 00 00 00       	mov    $0x0,%eax
  801166:	89 de                	mov    %ebx,%esi

	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9')
  801168:	0f b6 0a             	movzbl (%edx),%ecx
  80116b:	89 cf                	mov    %ecx,%edi
  80116d:	8d 59 d0             	lea    -0x30(%ecx),%ebx
  801170:	80 fb 09             	cmp    $0x9,%bl
  801173:	77 08                	ja     80117d <strtol+0xa2>
			dig = *s - '0';
  801175:	0f be c9             	movsbl %cl,%ecx
  801178:	83 e9 30             	sub    $0x30,%ecx
  80117b:	eb 1e                	jmp    80119b <strtol+0xc0>
		else if (*s >= 'a' && *s <= 'z')
  80117d:	8d 5f 9f             	lea    -0x61(%edi),%ebx
  801180:	80 fb 19             	cmp    $0x19,%bl
  801183:	77 08                	ja     80118d <strtol+0xb2>
			dig = *s - 'a' + 10;
  801185:	0f be c9             	movsbl %cl,%ecx
  801188:	83 e9 57             	sub    $0x57,%ecx
  80118b:	eb 0e                	jmp    80119b <strtol+0xc0>
		else if (*s >= 'A' && *s <= 'Z')
  80118d:	8d 5f bf             	lea    -0x41(%edi),%ebx
  801190:	80 fb 19             	cmp    $0x19,%bl
  801193:	77 15                	ja     8011aa <strtol+0xcf>
			dig = *s - 'A' + 10;
  801195:	0f be c9             	movsbl %cl,%ecx
  801198:	83 e9 37             	sub    $0x37,%ecx
		else
			break;
		if (dig >= base)
  80119b:	39 f1                	cmp    %esi,%ecx
  80119d:	7d 0b                	jge    8011aa <strtol+0xcf>
			break;
		s++, val = (val * base) + dig;
  80119f:	83 c2 01             	add    $0x1,%edx
  8011a2:	0f af c6             	imul   %esi,%eax
  8011a5:	8d 04 01             	lea    (%ecx,%eax,1),%eax
		// we don't properly detect overflow!
	}
  8011a8:	eb be                	jmp    801168 <strtol+0x8d>
  8011aa:	89 c1                	mov    %eax,%ecx

	if (endptr)
  8011ac:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  8011b0:	74 05                	je     8011b7 <strtol+0xdc>
		*endptr = (char *) s;
  8011b2:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  8011b5:	89 13                	mov    %edx,(%ebx)
	return (neg ? -val : val);
  8011b7:	89 ca                	mov    %ecx,%edx
  8011b9:	f7 da                	neg    %edx
  8011bb:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
  8011bf:	0f 45 c2             	cmovne %edx,%eax
}
  8011c2:	83 c4 04             	add    $0x4,%esp
  8011c5:	5b                   	pop    %ebx
  8011c6:	5e                   	pop    %esi
  8011c7:	5f                   	pop    %edi
  8011c8:	5d                   	pop    %ebp
  8011c9:	c3                   	ret    
	...

008011cc <sys_cgetc>:
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}

int
sys_cgetc(void)
{
  8011cc:	55                   	push   %ebp
  8011cd:	89 e5                	mov    %esp,%ebp
  8011cf:	83 ec 0c             	sub    $0xc,%esp
  8011d2:	89 1c 24             	mov    %ebx,(%esp)
  8011d5:	89 74 24 04          	mov    %esi,0x4(%esp)
  8011d9:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8011dd:	ba 00 00 00 00       	mov    $0x0,%edx
  8011e2:	b8 01 00 00 00       	mov    $0x1,%eax
  8011e7:	89 d1                	mov    %edx,%ecx
  8011e9:	89 d3                	mov    %edx,%ebx
  8011eb:	89 d7                	mov    %edx,%edi
  8011ed:	89 d6                	mov    %edx,%esi
  8011ef:	cd 30                	int    $0x30

int
sys_cgetc(void)
{
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
  8011f1:	8b 1c 24             	mov    (%esp),%ebx
  8011f4:	8b 74 24 04          	mov    0x4(%esp),%esi
  8011f8:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8011fc:	89 ec                	mov    %ebp,%esp
  8011fe:	5d                   	pop    %ebp
  8011ff:	c3                   	ret    

00801200 <sys_cputs>:
	return ret;
}

void
sys_cputs(const char *s, size_t len)
{
  801200:	55                   	push   %ebp
  801201:	89 e5                	mov    %esp,%ebp
  801203:	83 ec 0c             	sub    $0xc,%esp
  801206:	89 1c 24             	mov    %ebx,(%esp)
  801209:	89 74 24 04          	mov    %esi,0x4(%esp)
  80120d:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801211:	b8 00 00 00 00       	mov    $0x0,%eax
  801216:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801219:	8b 55 08             	mov    0x8(%ebp),%edx
  80121c:	89 c3                	mov    %eax,%ebx
  80121e:	89 c7                	mov    %eax,%edi
  801220:	89 c6                	mov    %eax,%esi
  801222:	cd 30                	int    $0x30

void
sys_cputs(const char *s, size_t len)
{
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
  801224:	8b 1c 24             	mov    (%esp),%ebx
  801227:	8b 74 24 04          	mov    0x4(%esp),%esi
  80122b:	8b 7c 24 08          	mov    0x8(%esp),%edi
  80122f:	89 ec                	mov    %ebp,%esp
  801231:	5d                   	pop    %ebp
  801232:	c3                   	ret    

00801233 <sys_ns_recv>:
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}

int
sys_ns_recv(void *pkt, uint32_t len)
{
  801233:	55                   	push   %ebp
  801234:	89 e5                	mov    %esp,%ebp
  801236:	83 ec 0c             	sub    $0xc,%esp
  801239:	89 1c 24             	mov    %ebx,(%esp)
  80123c:	89 74 24 04          	mov    %esi,0x4(%esp)
  801240:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801244:	bb 00 00 00 00       	mov    $0x0,%ebx
  801249:	b8 10 00 00 00       	mov    $0x10,%eax
  80124e:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801251:	8b 55 08             	mov    0x8(%ebp),%edx
  801254:	89 df                	mov    %ebx,%edi
  801256:	89 de                	mov    %ebx,%esi
  801258:	cd 30                	int    $0x30

int
sys_ns_recv(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_recv, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  80125a:	8b 1c 24             	mov    (%esp),%ebx
  80125d:	8b 74 24 04          	mov    0x4(%esp),%esi
  801261:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801265:	89 ec                	mov    %ebp,%esp
  801267:	5d                   	pop    %ebp
  801268:	c3                   	ret    

00801269 <sys_ns_send>:
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}

int
sys_ns_send(void *pkt, uint32_t len)
{
  801269:	55                   	push   %ebp
  80126a:	89 e5                	mov    %esp,%ebp
  80126c:	83 ec 0c             	sub    $0xc,%esp
  80126f:	89 1c 24             	mov    %ebx,(%esp)
  801272:	89 74 24 04          	mov    %esi,0x4(%esp)
  801276:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80127a:	bb 00 00 00 00       	mov    $0x0,%ebx
  80127f:	b8 0f 00 00 00       	mov    $0xf,%eax
  801284:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801287:	8b 55 08             	mov    0x8(%ebp),%edx
  80128a:	89 df                	mov    %ebx,%edi
  80128c:	89 de                	mov    %ebx,%esi
  80128e:	cd 30                	int    $0x30

int
sys_ns_send(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  801290:	8b 1c 24             	mov    (%esp),%ebx
  801293:	8b 74 24 04          	mov    0x4(%esp),%esi
  801297:	8b 7c 24 08          	mov    0x8(%esp),%edi
  80129b:	89 ec                	mov    %ebp,%esp
  80129d:	5d                   	pop    %ebp
  80129e:	c3                   	ret    

0080129f <sys_time_msec>:
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}

unsigned int
sys_time_msec(void)
{
  80129f:	55                   	push   %ebp
  8012a0:	89 e5                	mov    %esp,%ebp
  8012a2:	83 ec 0c             	sub    $0xc,%esp
  8012a5:	89 1c 24             	mov    %ebx,(%esp)
  8012a8:	89 74 24 04          	mov    %esi,0x4(%esp)
  8012ac:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8012b0:	ba 00 00 00 00       	mov    $0x0,%edx
  8012b5:	b8 0e 00 00 00       	mov    $0xe,%eax
  8012ba:	89 d1                	mov    %edx,%ecx
  8012bc:	89 d3                	mov    %edx,%ebx
  8012be:	89 d7                	mov    %edx,%edi
  8012c0:	89 d6                	mov    %edx,%esi
  8012c2:	cd 30                	int    $0x30

unsigned int
sys_time_msec(void)
{
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}
  8012c4:	8b 1c 24             	mov    (%esp),%ebx
  8012c7:	8b 74 24 04          	mov    0x4(%esp),%esi
  8012cb:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8012cf:	89 ec                	mov    %ebp,%esp
  8012d1:	5d                   	pop    %ebp
  8012d2:	c3                   	ret    

008012d3 <sys_ipc_recv>:
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}

int
sys_ipc_recv(void *dstva)
{
  8012d3:	55                   	push   %ebp
  8012d4:	89 e5                	mov    %esp,%ebp
  8012d6:	83 ec 38             	sub    $0x38,%esp
  8012d9:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8012dc:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8012df:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8012e2:	b9 00 00 00 00       	mov    $0x0,%ecx
  8012e7:	b8 0d 00 00 00       	mov    $0xd,%eax
  8012ec:	8b 55 08             	mov    0x8(%ebp),%edx
  8012ef:	89 cb                	mov    %ecx,%ebx
  8012f1:	89 cf                	mov    %ecx,%edi
  8012f3:	89 ce                	mov    %ecx,%esi
  8012f5:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8012f7:	85 c0                	test   %eax,%eax
  8012f9:	7e 28                	jle    801323 <sys_ipc_recv+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  8012fb:	89 44 24 10          	mov    %eax,0x10(%esp)
  8012ff:	c7 44 24 0c 0d 00 00 	movl   $0xd,0xc(%esp)
  801306:	00 
  801307:	c7 44 24 08 4b 3a 80 	movl   $0x803a4b,0x8(%esp)
  80130e:	00 
  80130f:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801316:	00 
  801317:	c7 04 24 68 3a 80 00 	movl   $0x803a68,(%esp)
  80131e:	e8 59 f3 ff ff       	call   80067c <_panic>

int
sys_ipc_recv(void *dstva)
{
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
  801323:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801326:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801329:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80132c:	89 ec                	mov    %ebp,%esp
  80132e:	5d                   	pop    %ebp
  80132f:	c3                   	ret    

00801330 <sys_ipc_try_send>:
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
  801330:	55                   	push   %ebp
  801331:	89 e5                	mov    %esp,%ebp
  801333:	83 ec 38             	sub    $0x38,%esp
  801336:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801339:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80133c:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80133f:	be 00 00 00 00       	mov    $0x0,%esi
  801344:	b8 0c 00 00 00       	mov    $0xc,%eax
  801349:	8b 7d 14             	mov    0x14(%ebp),%edi
  80134c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  80134f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801352:	8b 55 08             	mov    0x8(%ebp),%edx
  801355:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801357:	85 c0                	test   %eax,%eax
  801359:	7e 28                	jle    801383 <sys_ipc_try_send+0x53>
		panic("syscall %d returned %d (> 0)", num, ret);
  80135b:	89 44 24 10          	mov    %eax,0x10(%esp)
  80135f:	c7 44 24 0c 0c 00 00 	movl   $0xc,0xc(%esp)
  801366:	00 
  801367:	c7 44 24 08 4b 3a 80 	movl   $0x803a4b,0x8(%esp)
  80136e:	00 
  80136f:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801376:	00 
  801377:	c7 04 24 68 3a 80 00 	movl   $0x803a68,(%esp)
  80137e:	e8 f9 f2 ff ff       	call   80067c <_panic>

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}
  801383:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801386:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801389:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80138c:	89 ec                	mov    %ebp,%esp
  80138e:	5d                   	pop    %ebp
  80138f:	c3                   	ret    

00801390 <sys_env_set_pgfault_upcall>:
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
  801390:	55                   	push   %ebp
  801391:	89 e5                	mov    %esp,%ebp
  801393:	83 ec 38             	sub    $0x38,%esp
  801396:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801399:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80139c:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80139f:	bb 00 00 00 00       	mov    $0x0,%ebx
  8013a4:	b8 0a 00 00 00       	mov    $0xa,%eax
  8013a9:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8013ac:	8b 55 08             	mov    0x8(%ebp),%edx
  8013af:	89 df                	mov    %ebx,%edi
  8013b1:	89 de                	mov    %ebx,%esi
  8013b3:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8013b5:	85 c0                	test   %eax,%eax
  8013b7:	7e 28                	jle    8013e1 <sys_env_set_pgfault_upcall+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  8013b9:	89 44 24 10          	mov    %eax,0x10(%esp)
  8013bd:	c7 44 24 0c 0a 00 00 	movl   $0xa,0xc(%esp)
  8013c4:	00 
  8013c5:	c7 44 24 08 4b 3a 80 	movl   $0x803a4b,0x8(%esp)
  8013cc:	00 
  8013cd:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8013d4:	00 
  8013d5:	c7 04 24 68 3a 80 00 	movl   $0x803a68,(%esp)
  8013dc:	e8 9b f2 ff ff       	call   80067c <_panic>

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
  8013e1:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8013e4:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8013e7:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8013ea:	89 ec                	mov    %ebp,%esp
  8013ec:	5d                   	pop    %ebp
  8013ed:	c3                   	ret    

008013ee <sys_env_set_trapframe>:
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
  8013ee:	55                   	push   %ebp
  8013ef:	89 e5                	mov    %esp,%ebp
  8013f1:	83 ec 38             	sub    $0x38,%esp
  8013f4:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8013f7:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8013fa:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8013fd:	bb 00 00 00 00       	mov    $0x0,%ebx
  801402:	b8 09 00 00 00       	mov    $0x9,%eax
  801407:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80140a:	8b 55 08             	mov    0x8(%ebp),%edx
  80140d:	89 df                	mov    %ebx,%edi
  80140f:	89 de                	mov    %ebx,%esi
  801411:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801413:	85 c0                	test   %eax,%eax
  801415:	7e 28                	jle    80143f <sys_env_set_trapframe+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801417:	89 44 24 10          	mov    %eax,0x10(%esp)
  80141b:	c7 44 24 0c 09 00 00 	movl   $0x9,0xc(%esp)
  801422:	00 
  801423:	c7 44 24 08 4b 3a 80 	movl   $0x803a4b,0x8(%esp)
  80142a:	00 
  80142b:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801432:	00 
  801433:	c7 04 24 68 3a 80 00 	movl   $0x803a68,(%esp)
  80143a:	e8 3d f2 ff ff       	call   80067c <_panic>

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
  80143f:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801442:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801445:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801448:	89 ec                	mov    %ebp,%esp
  80144a:	5d                   	pop    %ebp
  80144b:	c3                   	ret    

0080144c <sys_env_set_status>:

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
  80144c:	55                   	push   %ebp
  80144d:	89 e5                	mov    %esp,%ebp
  80144f:	83 ec 38             	sub    $0x38,%esp
  801452:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801455:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801458:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80145b:	bb 00 00 00 00       	mov    $0x0,%ebx
  801460:	b8 08 00 00 00       	mov    $0x8,%eax
  801465:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801468:	8b 55 08             	mov    0x8(%ebp),%edx
  80146b:	89 df                	mov    %ebx,%edi
  80146d:	89 de                	mov    %ebx,%esi
  80146f:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801471:	85 c0                	test   %eax,%eax
  801473:	7e 28                	jle    80149d <sys_env_set_status+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801475:	89 44 24 10          	mov    %eax,0x10(%esp)
  801479:	c7 44 24 0c 08 00 00 	movl   $0x8,0xc(%esp)
  801480:	00 
  801481:	c7 44 24 08 4b 3a 80 	movl   $0x803a4b,0x8(%esp)
  801488:	00 
  801489:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801490:	00 
  801491:	c7 04 24 68 3a 80 00 	movl   $0x803a68,(%esp)
  801498:	e8 df f1 ff ff       	call   80067c <_panic>

int
sys_env_set_status(envid_t envid, int status)
{
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
  80149d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8014a0:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8014a3:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8014a6:	89 ec                	mov    %ebp,%esp
  8014a8:	5d                   	pop    %ebp
  8014a9:	c3                   	ret    

008014aa <sys_page_unmap>:
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}

int
sys_page_unmap(envid_t envid, void *va)
{
  8014aa:	55                   	push   %ebp
  8014ab:	89 e5                	mov    %esp,%ebp
  8014ad:	83 ec 38             	sub    $0x38,%esp
  8014b0:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8014b3:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8014b6:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8014b9:	bb 00 00 00 00       	mov    $0x0,%ebx
  8014be:	b8 06 00 00 00       	mov    $0x6,%eax
  8014c3:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8014c6:	8b 55 08             	mov    0x8(%ebp),%edx
  8014c9:	89 df                	mov    %ebx,%edi
  8014cb:	89 de                	mov    %ebx,%esi
  8014cd:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8014cf:	85 c0                	test   %eax,%eax
  8014d1:	7e 28                	jle    8014fb <sys_page_unmap+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  8014d3:	89 44 24 10          	mov    %eax,0x10(%esp)
  8014d7:	c7 44 24 0c 06 00 00 	movl   $0x6,0xc(%esp)
  8014de:	00 
  8014df:	c7 44 24 08 4b 3a 80 	movl   $0x803a4b,0x8(%esp)
  8014e6:	00 
  8014e7:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8014ee:	00 
  8014ef:	c7 04 24 68 3a 80 00 	movl   $0x803a68,(%esp)
  8014f6:	e8 81 f1 ff ff       	call   80067c <_panic>

int
sys_page_unmap(envid_t envid, void *va)
{
	return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
  8014fb:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8014fe:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801501:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801504:	89 ec                	mov    %ebp,%esp
  801506:	5d                   	pop    %ebp
  801507:	c3                   	ret    

00801508 <sys_page_map>:
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
  801508:	55                   	push   %ebp
  801509:	89 e5                	mov    %esp,%ebp
  80150b:	83 ec 38             	sub    $0x38,%esp
  80150e:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801511:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801514:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801517:	b8 05 00 00 00       	mov    $0x5,%eax
  80151c:	8b 75 18             	mov    0x18(%ebp),%esi
  80151f:	8b 7d 14             	mov    0x14(%ebp),%edi
  801522:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801525:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801528:	8b 55 08             	mov    0x8(%ebp),%edx
  80152b:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80152d:	85 c0                	test   %eax,%eax
  80152f:	7e 28                	jle    801559 <sys_page_map+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801531:	89 44 24 10          	mov    %eax,0x10(%esp)
  801535:	c7 44 24 0c 05 00 00 	movl   $0x5,0xc(%esp)
  80153c:	00 
  80153d:	c7 44 24 08 4b 3a 80 	movl   $0x803a4b,0x8(%esp)
  801544:	00 
  801545:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80154c:	00 
  80154d:	c7 04 24 68 3a 80 00 	movl   $0x803a68,(%esp)
  801554:	e8 23 f1 ff ff       	call   80067c <_panic>

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
  801559:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80155c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80155f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801562:	89 ec                	mov    %ebp,%esp
  801564:	5d                   	pop    %ebp
  801565:	c3                   	ret    

00801566 <sys_page_alloc>:
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
  801566:	55                   	push   %ebp
  801567:	89 e5                	mov    %esp,%ebp
  801569:	83 ec 38             	sub    $0x38,%esp
  80156c:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  80156f:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801572:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801575:	be 00 00 00 00       	mov    $0x0,%esi
  80157a:	b8 04 00 00 00       	mov    $0x4,%eax
  80157f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801582:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801585:	8b 55 08             	mov    0x8(%ebp),%edx
  801588:	89 f7                	mov    %esi,%edi
  80158a:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80158c:	85 c0                	test   %eax,%eax
  80158e:	7e 28                	jle    8015b8 <sys_page_alloc+0x52>
		panic("syscall %d returned %d (> 0)", num, ret);
  801590:	89 44 24 10          	mov    %eax,0x10(%esp)
  801594:	c7 44 24 0c 04 00 00 	movl   $0x4,0xc(%esp)
  80159b:	00 
  80159c:	c7 44 24 08 4b 3a 80 	movl   $0x803a4b,0x8(%esp)
  8015a3:	00 
  8015a4:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8015ab:	00 
  8015ac:	c7 04 24 68 3a 80 00 	movl   $0x803a68,(%esp)
  8015b3:	e8 c4 f0 ff ff       	call   80067c <_panic>

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
  8015b8:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8015bb:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8015be:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8015c1:	89 ec                	mov    %ebp,%esp
  8015c3:	5d                   	pop    %ebp
  8015c4:	c3                   	ret    

008015c5 <sys_yield>:
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}

void
sys_yield(void)
{
  8015c5:	55                   	push   %ebp
  8015c6:	89 e5                	mov    %esp,%ebp
  8015c8:	83 ec 0c             	sub    $0xc,%esp
  8015cb:	89 1c 24             	mov    %ebx,(%esp)
  8015ce:	89 74 24 04          	mov    %esi,0x4(%esp)
  8015d2:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8015d6:	ba 00 00 00 00       	mov    $0x0,%edx
  8015db:	b8 0b 00 00 00       	mov    $0xb,%eax
  8015e0:	89 d1                	mov    %edx,%ecx
  8015e2:	89 d3                	mov    %edx,%ebx
  8015e4:	89 d7                	mov    %edx,%edi
  8015e6:	89 d6                	mov    %edx,%esi
  8015e8:	cd 30                	int    $0x30

void
sys_yield(void)
{
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
  8015ea:	8b 1c 24             	mov    (%esp),%ebx
  8015ed:	8b 74 24 04          	mov    0x4(%esp),%esi
  8015f1:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8015f5:	89 ec                	mov    %ebp,%esp
  8015f7:	5d                   	pop    %ebp
  8015f8:	c3                   	ret    

008015f9 <sys_getenvid>:
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}

envid_t
sys_getenvid(void)
{
  8015f9:	55                   	push   %ebp
  8015fa:	89 e5                	mov    %esp,%ebp
  8015fc:	83 ec 0c             	sub    $0xc,%esp
  8015ff:	89 1c 24             	mov    %ebx,(%esp)
  801602:	89 74 24 04          	mov    %esi,0x4(%esp)
  801606:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80160a:	ba 00 00 00 00       	mov    $0x0,%edx
  80160f:	b8 02 00 00 00       	mov    $0x2,%eax
  801614:	89 d1                	mov    %edx,%ecx
  801616:	89 d3                	mov    %edx,%ebx
  801618:	89 d7                	mov    %edx,%edi
  80161a:	89 d6                	mov    %edx,%esi
  80161c:	cd 30                	int    $0x30

envid_t
sys_getenvid(void)
{
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
  80161e:	8b 1c 24             	mov    (%esp),%ebx
  801621:	8b 74 24 04          	mov    0x4(%esp),%esi
  801625:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801629:	89 ec                	mov    %ebp,%esp
  80162b:	5d                   	pop    %ebp
  80162c:	c3                   	ret    

0080162d <sys_env_destroy>:
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}

int
sys_env_destroy(envid_t envid)
{
  80162d:	55                   	push   %ebp
  80162e:	89 e5                	mov    %esp,%ebp
  801630:	83 ec 38             	sub    $0x38,%esp
  801633:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801636:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801639:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80163c:	b9 00 00 00 00       	mov    $0x0,%ecx
  801641:	b8 03 00 00 00       	mov    $0x3,%eax
  801646:	8b 55 08             	mov    0x8(%ebp),%edx
  801649:	89 cb                	mov    %ecx,%ebx
  80164b:	89 cf                	mov    %ecx,%edi
  80164d:	89 ce                	mov    %ecx,%esi
  80164f:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801651:	85 c0                	test   %eax,%eax
  801653:	7e 28                	jle    80167d <sys_env_destroy+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  801655:	89 44 24 10          	mov    %eax,0x10(%esp)
  801659:	c7 44 24 0c 03 00 00 	movl   $0x3,0xc(%esp)
  801660:	00 
  801661:	c7 44 24 08 4b 3a 80 	movl   $0x803a4b,0x8(%esp)
  801668:	00 
  801669:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801670:	00 
  801671:	c7 04 24 68 3a 80 00 	movl   $0x803a68,(%esp)
  801678:	e8 ff ef ff ff       	call   80067c <_panic>

int
sys_env_destroy(envid_t envid)
{
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
  80167d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801680:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801683:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801686:	89 ec                	mov    %ebp,%esp
  801688:	5d                   	pop    %ebp
  801689:	c3                   	ret    
  80168a:	00 00                	add    %al,(%eax)
  80168c:	00 00                	add    %al,(%eax)
	...

00801690 <sfork>:
}

// Challenge!
int
sfork(void)
{
  801690:	55                   	push   %ebp
  801691:	89 e5                	mov    %esp,%ebp
  801693:	83 ec 18             	sub    $0x18,%esp
	panic("sfork not implemented");
  801696:	c7 44 24 08 76 3a 80 	movl   $0x803a76,0x8(%esp)
  80169d:	00 
  80169e:	c7 44 24 04 9a 00 00 	movl   $0x9a,0x4(%esp)
  8016a5:	00 
  8016a6:	c7 04 24 8c 3a 80 00 	movl   $0x803a8c,(%esp)
  8016ad:	e8 ca ef ff ff       	call   80067c <_panic>

008016b2 <fork>:
//   Neither user exception stack should ever be marked copy-on-write,
//   so you must allocate a new page for the child's user exception stack.
//
envid_t
fork(void)
{
  8016b2:	55                   	push   %ebp
  8016b3:	89 e5                	mov    %esp,%ebp
  8016b5:	57                   	push   %edi
  8016b6:	56                   	push   %esi
  8016b7:	53                   	push   %ebx
  8016b8:	83 ec 3c             	sub    $0x3c,%esp
    int r   = 0;
    int i;
    envid_t childId = 0;
	// LAB 4: Your code here.
    // Setup parent process pgfault handler.
    set_pgfault_handler(pgfault);
  8016bb:	c7 04 24 1c 19 80 00 	movl   $0x80191c,(%esp)
  8016c2:	e8 2d 18 00 00       	call   802ef4 <set_pgfault_handler>
static __inline envid_t sys_exofork(void) __attribute__((always_inline));
static __inline envid_t
sys_exofork(void)
{
	envid_t ret;
	__asm __volatile("int %2"
  8016c7:	ba 07 00 00 00       	mov    $0x7,%edx
  8016cc:	89 d0                	mov    %edx,%eax
  8016ce:	cd 30                	int    $0x30
  8016d0:	89 45 d8             	mov    %eax,-0x28(%ebp)
    childId=sys_exofork();

    if (childId<0) {
  8016d3:	85 c0                	test   %eax,%eax
  8016d5:	79 20                	jns    8016f7 <fork+0x45>
        panic("Parent: sys_exofork. Error: 0x%x\n", childId);
  8016d7:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8016db:	c7 44 24 08 fc 3a 80 	movl   $0x803afc,0x8(%esp)
  8016e2:	00 
  8016e3:	c7 44 24 04 7b 00 00 	movl   $0x7b,0x4(%esp)
  8016ea:	00 
  8016eb:	c7 04 24 8c 3a 80 00 	movl   $0x803a8c,(%esp)
  8016f2:	e8 85 ef ff ff       	call   80067c <_panic>
    } else if (childId>0) {
  8016f7:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  8016fb:	0f 8e f3 01 00 00    	jle    8018f4 <fork+0x242>
      // Setup child process' pgfault handler.
      if ((r=sys_env_set_pgfault_upcall(childId, _pgfault_upcall))) {
  801701:	c7 44 24 04 64 2f 80 	movl   $0x802f64,0x4(%esp)
  801708:	00 
  801709:	8b 45 d8             	mov    -0x28(%ebp),%eax
  80170c:	89 04 24             	mov    %eax,(%esp)
  80170f:	e8 7c fc ff ff       	call   801390 <sys_env_set_pgfault_upcall>
  801714:	85 c0                	test   %eax,%eax
  801716:	74 20                	je     801738 <fork+0x86>
          panic("Child: sys_env_set_pgfault_upcall. Error: %d\n", r);
  801718:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80171c:	c7 44 24 08 20 3b 80 	movl   $0x803b20,0x8(%esp)
  801723:	00 
  801724:	c7 44 24 04 7f 00 00 	movl   $0x7f,0x4(%esp)
  80172b:	00 
  80172c:	c7 04 24 8c 3a 80 00 	movl   $0x803a8c,(%esp)
  801733:	e8 44 ef ff ff       	call   80067c <_panic>
      }
      
      // Setup child's Image.
      // Allocate page for child's user exception stack.
      if ((r=sys_page_alloc(childId, (void *)(UXSTACKTOP-PGSIZE), PTE_U|PTE_P|PTE_W))<0) {
  801738:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  80173f:	00 
  801740:	c7 44 24 04 00 f0 bf 	movl   $0xeebff000,0x4(%esp)
  801747:	ee 
  801748:	8b 45 d8             	mov    -0x28(%ebp),%eax
  80174b:	89 04 24             	mov    %eax,(%esp)
  80174e:	e8 13 fe ff ff       	call   801566 <sys_page_alloc>
  801753:	85 c0                	test   %eax,%eax
  801755:	79 20                	jns    801777 <fork+0xc5>
          panic("Parent: sys_page_alloc. Error: 0x%x\n", r);           
  801757:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80175b:	c7 44 24 08 50 3b 80 	movl   $0x803b50,0x8(%esp)
  801762:	00 
  801763:	c7 44 24 04 85 00 00 	movl   $0x85,0x4(%esp)
  80176a:	00 
  80176b:	c7 04 24 8c 3a 80 00 	movl   $0x803a8c,(%esp)
  801772:	e8 05 ef ff ff       	call   80067c <_panic>
  801777:	be 00 00 80 00       	mov    $0x800000,%esi
  80177c:	bb 00 00 80 00       	mov    $0x800000,%ebx
      }

      // Copy Parent's address space to child.
      for (i=UTEXT;i<USTACKTOP;i+=PGSIZE)
        if (vpd[VPD(i)]&PTE_P)
  801781:	bf 00 d0 7b ef       	mov    $0xef7bd000,%edi
  801786:	89 f0                	mov    %esi,%eax
  801788:	c1 e8 16             	shr    $0x16,%eax
  80178b:	8b 04 87             	mov    (%edi,%eax,4),%eax
  80178e:	a8 01                	test   $0x1,%al
  801790:	0f 84 13 01 00 00    	je     8018a9 <fork+0x1f7>
// 
static int
duppage(envid_t envid, unsigned pn)
{
	int r           = 0;
  int perm        = vpt[VPN(pn)]&PTE_USER;
  801796:	89 f0                	mov    %esi,%eax
  801798:	c1 e8 0c             	shr    $0xc,%eax
  80179b:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  8017a2:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  8017a5:	25 07 0e 00 00       	and    $0xe07,%eax
  8017aa:	89 45 e0             	mov    %eax,-0x20(%ebp)
  envid_t env_id  = sys_getenvid();
  8017ad:	e8 47 fe ff ff       	call   8015f9 <sys_getenvid>
  8017b2:	89 45 dc             	mov    %eax,-0x24(%ebp)

	// LAB 4: Your code here.
  if ((perm&PTE_P) && (perm&PTE_W || perm&PTE_COW) && (!(perm&PTE_SHARE))) {
  8017b5:	f6 45 e4 01          	testb  $0x1,-0x1c(%ebp)
  8017b9:	0f 84 ea 00 00 00    	je     8018a9 <fork+0x1f7>
  8017bf:	f7 45 e0 02 08 00 00 	testl  $0x802,-0x20(%ebp)
  8017c6:	0f 84 9d 00 00 00    	je     801869 <fork+0x1b7>
  8017cc:	f7 45 e0 00 04 00 00 	testl  $0x400,-0x20(%ebp)
  8017d3:	0f 85 90 00 00 00    	jne    801869 <fork+0x1b7>
    perm    &= (~PTE_W);
  8017d9:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8017dc:	83 e0 fd             	and    $0xfffffffd,%eax
    perm    |= PTE_COW;
  8017df:	80 cc 08             	or     $0x8,%ah
  8017e2:	89 45 e4             	mov    %eax,-0x1c(%ebp)
    
    if ((r=sys_page_map(env_id, (void *)pn, envid, (void *)pn, perm))<0)
  8017e5:	89 75 e0             	mov    %esi,-0x20(%ebp)
  8017e8:	89 44 24 10          	mov    %eax,0x10(%esp)
  8017ec:	89 74 24 0c          	mov    %esi,0xc(%esp)
  8017f0:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8017f3:	89 44 24 08          	mov    %eax,0x8(%esp)
  8017f7:	89 74 24 04          	mov    %esi,0x4(%esp)
  8017fb:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8017fe:	89 04 24             	mov    %eax,(%esp)
  801801:	e8 02 fd ff ff       	call   801508 <sys_page_map>
  801806:	85 c0                	test   %eax,%eax
  801808:	79 1b                	jns    801825 <fork+0x173>
      cprintf("[0x%x] Mapping to CHILD: sys_page_map. Address 0x%x. Error: %d\n", env_id, pn, r);
  80180a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80180e:	89 74 24 08          	mov    %esi,0x8(%esp)
  801812:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801815:	89 44 24 04          	mov    %eax,0x4(%esp)
  801819:	c7 04 24 78 3b 80 00 	movl   $0x803b78,(%esp)
  801820:	e8 1c ef ff ff       	call   800741 <cprintf>
    // Map permissions back to parent on COW.
    if ((r=sys_page_map(envid, (void *)pn, env_id, (void *)pn, perm))<0)
  801825:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801828:	89 44 24 10          	mov    %eax,0x10(%esp)
  80182c:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80182f:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801833:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801836:	89 44 24 08          	mov    %eax,0x8(%esp)
  80183a:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80183d:	89 44 24 04          	mov    %eax,0x4(%esp)
  801841:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801844:	89 04 24             	mov    %eax,(%esp)
  801847:	e8 bc fc ff ff       	call   801508 <sys_page_map>
  80184c:	85 c0                	test   %eax,%eax
  80184e:	79 59                	jns    8018a9 <fork+0x1f7>
      cprintf("[0x%x] Mapping to PARENT: sys_page_map. Error: %d\n", env_id, r);
  801850:	89 44 24 08          	mov    %eax,0x8(%esp)
  801854:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801857:	89 44 24 04          	mov    %eax,0x4(%esp)
  80185b:	c7 04 24 b8 3b 80 00 	movl   $0x803bb8,(%esp)
  801862:	e8 da ee ff ff       	call   800741 <cprintf>
  801867:	eb 40                	jmp    8018a9 <fork+0x1f7>
  } else if (perm&PTE_P){
    if ((r=sys_page_map(env_id, (void *)pn, envid, (void *)pn, perm))<0)
  801869:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80186c:	89 44 24 10          	mov    %eax,0x10(%esp)
  801870:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801874:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801877:	89 44 24 08          	mov    %eax,0x8(%esp)
  80187b:	89 74 24 04          	mov    %esi,0x4(%esp)
  80187f:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801882:	89 04 24             	mov    %eax,(%esp)
  801885:	e8 7e fc ff ff       	call   801508 <sys_page_map>
  80188a:	85 c0                	test   %eax,%eax
  80188c:	79 1b                	jns    8018a9 <fork+0x1f7>
      cprintf("[0x%x] Mapping to CHILD: sys_page_map. Address 0x%x. Error: %d\n", env_id, pn, r);
  80188e:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801892:	89 74 24 08          	mov    %esi,0x8(%esp)
  801896:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801899:	89 44 24 04          	mov    %eax,0x4(%esp)
  80189d:	c7 04 24 78 3b 80 00 	movl   $0x803b78,(%esp)
  8018a4:	e8 98 ee ff ff       	call   800741 <cprintf>
      if ((r=sys_page_alloc(childId, (void *)(UXSTACKTOP-PGSIZE), PTE_U|PTE_P|PTE_W))<0) {
          panic("Parent: sys_page_alloc. Error: 0x%x\n", r);           
      }

      // Copy Parent's address space to child.
      for (i=UTEXT;i<USTACKTOP;i+=PGSIZE)
  8018a9:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  8018af:	89 de                	mov    %ebx,%esi
  8018b1:	81 fb 00 e0 bf ee    	cmp    $0xeebfe000,%ebx
  8018b7:	0f 85 c9 fe ff ff    	jne    801786 <fork+0xd4>
        if (vpd[VPD(i)]&PTE_P)
          duppage(childId, i);

      // Set child as runnable.
      if ((r = sys_env_set_status(childId, ENV_RUNNABLE)) < 0)
  8018bd:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  8018c4:	00 
  8018c5:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8018c8:	89 04 24             	mov    %eax,(%esp)
  8018cb:	e8 7c fb ff ff       	call   80144c <sys_env_set_status>
  8018d0:	85 c0                	test   %eax,%eax
  8018d2:	79 3d                	jns    801911 <fork+0x25f>
        panic("Parent: sys_env_set_status: %e\n", r);
  8018d4:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8018d8:	c7 44 24 08 ec 3b 80 	movl   $0x803bec,0x8(%esp)
  8018df:	00 
  8018e0:	c7 44 24 04 8f 00 00 	movl   $0x8f,0x4(%esp)
  8018e7:	00 
  8018e8:	c7 04 24 8c 3a 80 00 	movl   $0x803a8c,(%esp)
  8018ef:	e8 88 ed ff ff       	call   80067c <_panic>
    } else if (childId==0) {
  8018f4:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  8018f8:	75 17                	jne    801911 <fork+0x25f>
      env = &envs [ENVX(sys_getenvid())];
  8018fa:	e8 fa fc ff ff       	call   8015f9 <sys_getenvid>
  8018ff:	25 ff 03 00 00       	and    $0x3ff,%eax
  801904:	6b c0 7c             	imul   $0x7c,%eax,%eax
  801907:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  80190c:	a3 8c 70 80 00       	mov    %eax,0x80708c
    }
    return childId;
}
  801911:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801914:	83 c4 3c             	add    $0x3c,%esp
  801917:	5b                   	pop    %ebx
  801918:	5e                   	pop    %esi
  801919:	5f                   	pop    %edi
  80191a:	5d                   	pop    %ebp
  80191b:	c3                   	ret    

0080191c <pgfault>:
// Custom page fault handler - if faulting page is copy-on-write,
// map in our own private writable copy.
//
static void
pgfault(struct UTrapframe *utf)
{
  80191c:	55                   	push   %ebp
  80191d:	89 e5                	mov    %esp,%ebp
  80191f:	57                   	push   %edi
  801920:	56                   	push   %esi
  801921:	53                   	push   %ebx
  801922:	83 ec 3c             	sub    $0x3c,%esp
  void *addr    = (void *) utf->utf_fault_va;
  801925:	8b 45 08             	mov    0x8(%ebp),%eax
  801928:	8b 38                	mov    (%eax),%edi
  uint32_t err  = utf->utf_err;
  80192a:	8b 50 04             	mov    0x4(%eax),%edx
  80192d:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  int r         = 0;
  int perm      = 0;
  void *align   = (void *)((int)addr&(~0xFFF));
  801930:	89 fe                	mov    %edi,%esi
  801932:	81 e6 00 f0 ff ff    	and    $0xfffff000,%esi
  envid_t envid = sys_getenvid();
  801938:	e8 bc fc ff ff       	call   8015f9 <sys_getenvid>
  80193d:	89 c3                	mov    %eax,%ebx
	// copy-on-write page.  If not, panic.
	// Hint:
	//   Use the read-only page table mappings at vpt
	//   (see <inc/memlayout.h>).

  if ((vpd[VPD(align)]&PTE_P) && (vpt[VPN(align)]&PTE_P))
  80193f:	89 f2                	mov    %esi,%edx
  801941:	89 f0                	mov    %esi,%eax
  801943:	c1 e8 16             	shr    $0x16,%eax
  801946:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  80194d:	a8 01                	test   $0x1,%al
  80194f:	74 3e                	je     80198f <pgfault+0x73>
  801951:	c1 ea 0c             	shr    $0xc,%edx
  801954:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  80195b:	a8 01                	test   $0x1,%al
  80195d:	74 30                	je     80198f <pgfault+0x73>
    perm  = vpt[VPN(addr)]&PTE_USER;
  80195f:	c1 ef 0c             	shr    $0xc,%edi
  801962:	8b 3c bd 00 00 40 ef 	mov    -0x10c00000(,%edi,4),%edi
	// page to the old page's address.
	// Hint:
	//   You should make three system calls.
	//   No need to explicitly delete the old page's mapping.
	// LAB 4: Your code here.
  perm    &= (~PTE_COW);
  801969:	81 e7 07 06 00 00    	and    $0x607,%edi
  perm    |= PTE_W;
  80196f:	83 cf 02             	or     $0x2,%edi
  if (!(r=sys_page_alloc(envid, (void *)PFTEMP, perm))) {
  801972:	89 7c 24 08          	mov    %edi,0x8(%esp)
  801976:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  80197d:	00 
  80197e:	89 1c 24             	mov    %ebx,(%esp)
  801981:	e8 e0 fb ff ff       	call   801566 <sys_page_alloc>
  801986:	85 c0                	test   %eax,%eax
  801988:	74 46                	je     8019d0 <pgfault+0xb4>
  80198a:	e9 cd 00 00 00       	jmp    801a5c <pgfault+0x140>
	//   (see <inc/memlayout.h>).

  if ((vpd[VPD(align)]&PTE_P) && (vpt[VPN(align)]&PTE_P))
    perm  = vpt[VPN(addr)]&PTE_USER;
  else {
    cprintf("Tryig to acess address: %x eip: %x Err: %x\n", align, utf->utf_eip, err);
  80198f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801992:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801996:	8b 55 08             	mov    0x8(%ebp),%edx
  801999:	8b 42 28             	mov    0x28(%edx),%eax
  80199c:	89 44 24 08          	mov    %eax,0x8(%esp)
  8019a0:	89 74 24 04          	mov    %esi,0x4(%esp)
  8019a4:	c7 04 24 0c 3c 80 00 	movl   $0x803c0c,(%esp)
  8019ab:	e8 91 ed ff ff       	call   800741 <cprintf>
    panic("Go to hell :[%x]\n", envid);
  8019b0:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8019b4:	c7 44 24 08 97 3a 80 	movl   $0x803a97,0x8(%esp)
  8019bb:	00 
  8019bc:	c7 44 24 04 24 00 00 	movl   $0x24,0x4(%esp)
  8019c3:	00 
  8019c4:	c7 04 24 8c 3a 80 00 	movl   $0x803a8c,(%esp)
  8019cb:	e8 ac ec ff ff       	call   80067c <_panic>
	//   No need to explicitly delete the old page's mapping.
	// LAB 4: Your code here.
  perm    &= (~PTE_COW);
  perm    |= PTE_W;
  if (!(r=sys_page_alloc(envid, (void *)PFTEMP, perm))) {
    memmove((void *)PFTEMP, align, PGSIZE);
  8019d0:	c7 44 24 08 00 10 00 	movl   $0x1000,0x8(%esp)
  8019d7:	00 
  8019d8:	89 74 24 04          	mov    %esi,0x4(%esp)
  8019dc:	c7 04 24 00 f0 7f 00 	movl   $0x7ff000,(%esp)
  8019e3:	e8 dd f5 ff ff       	call   800fc5 <memmove>
    if((r=sys_page_map(envid, (void *)PFTEMP, envid, align, perm)))
  8019e8:	89 7c 24 10          	mov    %edi,0x10(%esp)
  8019ec:	89 74 24 0c          	mov    %esi,0xc(%esp)
  8019f0:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8019f4:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  8019fb:	00 
  8019fc:	89 1c 24             	mov    %ebx,(%esp)
  8019ff:	e8 04 fb ff ff       	call   801508 <sys_page_map>
  801a04:	85 c0                	test   %eax,%eax
  801a06:	74 20                	je     801a28 <pgfault+0x10c>
      panic("sys_page_map. Error: 0x%x\n", r);
  801a08:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801a0c:	c7 44 24 08 a9 3a 80 	movl   $0x803aa9,0x8(%esp)
  801a13:	00 
  801a14:	c7 44 24 04 34 00 00 	movl   $0x34,0x4(%esp)
  801a1b:	00 
  801a1c:	c7 04 24 8c 3a 80 00 	movl   $0x803a8c,(%esp)
  801a23:	e8 54 ec ff ff       	call   80067c <_panic>

    if ((r=sys_page_unmap(envid, (void *)PFTEMP)))
  801a28:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  801a2f:	00 
  801a30:	89 1c 24             	mov    %ebx,(%esp)
  801a33:	e8 72 fa ff ff       	call   8014aa <sys_page_unmap>
  801a38:	85 c0                	test   %eax,%eax
  801a3a:	74 40                	je     801a7c <pgfault+0x160>
      panic("sys_page_unmap. Error: 0x%x\n", r);
  801a3c:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801a40:	c7 44 24 08 c4 3a 80 	movl   $0x803ac4,0x8(%esp)
  801a47:	00 
  801a48:	c7 44 24 04 37 00 00 	movl   $0x37,0x4(%esp)
  801a4f:	00 
  801a50:	c7 04 24 8c 3a 80 00 	movl   $0x803a8c,(%esp)
  801a57:	e8 20 ec ff ff       	call   80067c <_panic>
  } else
    panic("sys_page_alloc. Error: %d\n", r);
  801a5c:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801a60:	c7 44 24 08 e1 3a 80 	movl   $0x803ae1,0x8(%esp)
  801a67:	00 
  801a68:	c7 44 24 04 39 00 00 	movl   $0x39,0x4(%esp)
  801a6f:	00 
  801a70:	c7 04 24 8c 3a 80 00 	movl   $0x803a8c,(%esp)
  801a77:	e8 00 ec ff ff       	call   80067c <_panic>
}
  801a7c:	83 c4 3c             	add    $0x3c,%esp
  801a7f:	5b                   	pop    %ebx
  801a80:	5e                   	pop    %esi
  801a81:	5f                   	pop    %edi
  801a82:	5d                   	pop    %ebp
  801a83:	c3                   	ret    
	...

00801a90 <ipc_send>:
//   Use sys_yield() to be CPU-friendly.
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
  801a90:	55                   	push   %ebp
  801a91:	89 e5                	mov    %esp,%ebp
  801a93:	57                   	push   %edi
  801a94:	56                   	push   %esi
  801a95:	53                   	push   %ebx
  801a96:	83 ec 2c             	sub    $0x2c,%esp
  801a99:	8b 75 08             	mov    0x8(%ebp),%esi
  801a9c:	8b 7d 0c             	mov    0xc(%ebp),%edi
  801a9f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
  801aa2:	85 db                	test   %ebx,%ebx
  801aa4:	b8 00 00 c0 ee       	mov    $0xeec00000,%eax
  801aa9:	0f 45 c3             	cmovne %ebx,%eax
  801aac:	8b 55 14             	mov    0x14(%ebp),%edx
  801aaf:	89 54 24 0c          	mov    %edx,0xc(%esp)
  801ab3:	89 44 24 08          	mov    %eax,0x8(%esp)
  801ab7:	89 7c 24 04          	mov    %edi,0x4(%esp)
  801abb:	89 34 24             	mov    %esi,(%esp)
  801abe:	e8 6d f8 ff ff       	call   801330 <sys_ipc_try_send>
  801ac3:	83 f8 f9             	cmp    $0xfffffff9,%eax
  801ac6:	75 0a                	jne    801ad2 <ipc_send+0x42>
      sys_yield();
  801ac8:	e8 f8 fa ff ff       	call   8015c5 <sys_yield>
    else if (r < 0)
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
    else
      return;
  }
  801acd:	8d 76 00             	lea    0x0(%esi),%esi
  801ad0:	eb d0                	jmp    801aa2 <ipc_send+0x12>
{
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
      sys_yield();
    else if (r < 0)
  801ad2:	85 c0                	test   %eax,%eax
  801ad4:	79 24                	jns    801afa <ipc_send+0x6a>
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
  801ad6:	89 44 24 10          	mov    %eax,0x10(%esp)
  801ada:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801ade:	c7 44 24 08 38 3c 80 	movl   $0x803c38,0x8(%esp)
  801ae5:	00 
  801ae6:	c7 44 24 04 36 00 00 	movl   $0x36,0x4(%esp)
  801aed:	00 
  801aee:	c7 04 24 5c 3c 80 00 	movl   $0x803c5c,(%esp)
  801af5:	e8 82 eb ff ff       	call   80067c <_panic>
    else
      return;
  }
}
  801afa:	83 c4 2c             	add    $0x2c,%esp
  801afd:	5b                   	pop    %ebx
  801afe:	5e                   	pop    %esi
  801aff:	5f                   	pop    %edi
  801b00:	5d                   	pop    %ebp
  801b01:	c3                   	ret    

00801b02 <ipc_recv>:
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value, since that's
//   a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
  801b02:	55                   	push   %ebp
  801b03:	89 e5                	mov    %esp,%ebp
  801b05:	56                   	push   %esi
  801b06:	53                   	push   %ebx
  801b07:	83 ec 10             	sub    $0x10,%esp
  801b0a:	8b 5d 08             	mov    0x8(%ebp),%ebx
  801b0d:	8b 45 0c             	mov    0xc(%ebp),%eax
  801b10:	8b 75 10             	mov    0x10(%ebp),%esi
  int r;
  if ((r=sys_ipc_recv((pg==NULL?(void *)UTOP:pg)))<0)
  801b13:	85 c0                	test   %eax,%eax
  801b15:	ba 00 00 c0 ee       	mov    $0xeec00000,%edx
  801b1a:	0f 44 c2             	cmove  %edx,%eax
  801b1d:	89 04 24             	mov    %eax,(%esp)
  801b20:	e8 ae f7 ff ff       	call   8012d3 <sys_ipc_recv>
  801b25:	85 c0                	test   %eax,%eax
  801b27:	78 24                	js     801b4d <ipc_recv+0x4b>
    return r;

  if (from_env_store)
  801b29:	85 db                	test   %ebx,%ebx
  801b2b:	74 0a                	je     801b37 <ipc_recv+0x35>
    *from_env_store = env->env_ipc_from;
  801b2d:	a1 8c 70 80 00       	mov    0x80708c,%eax
  801b32:	8b 40 74             	mov    0x74(%eax),%eax
  801b35:	89 03                	mov    %eax,(%ebx)

  if (perm_store)
  801b37:	85 f6                	test   %esi,%esi
  801b39:	74 0a                	je     801b45 <ipc_recv+0x43>
    *perm_store     = env->env_ipc_perm;
  801b3b:	a1 8c 70 80 00       	mov    0x80708c,%eax
  801b40:	8b 40 78             	mov    0x78(%eax),%eax
  801b43:	89 06                	mov    %eax,(%esi)

  return env->env_ipc_value;
  801b45:	a1 8c 70 80 00       	mov    0x80708c,%eax
  801b4a:	8b 40 70             	mov    0x70(%eax),%eax
}
  801b4d:	83 c4 10             	add    $0x10,%esp
  801b50:	5b                   	pop    %ebx
  801b51:	5e                   	pop    %esi
  801b52:	5d                   	pop    %ebp
  801b53:	c3                   	ret    
	...

00801b60 <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------

int
fd2num(struct Fd *fd)
{
  801b60:	55                   	push   %ebp
  801b61:	89 e5                	mov    %esp,%ebp
  801b63:	8b 45 08             	mov    0x8(%ebp),%eax
  801b66:	05 00 00 00 30       	add    $0x30000000,%eax
  801b6b:	c1 e8 0c             	shr    $0xc,%eax
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
}
  801b6e:	5d                   	pop    %ebp
  801b6f:	c3                   	ret    

00801b70 <fd2data>:

char*
fd2data(struct Fd *fd)
{
  801b70:	55                   	push   %ebp
  801b71:	89 e5                	mov    %esp,%ebp
  801b73:	83 ec 04             	sub    $0x4,%esp
	return INDEX2DATA(fd2num(fd));
  801b76:	8b 45 08             	mov    0x8(%ebp),%eax
  801b79:	89 04 24             	mov    %eax,(%esp)
  801b7c:	e8 df ff ff ff       	call   801b60 <fd2num>
  801b81:	05 20 00 0d 00       	add    $0xd0020,%eax
  801b86:	c1 e0 0c             	shl    $0xc,%eax
}
  801b89:	c9                   	leave  
  801b8a:	c3                   	ret    

00801b8b <fd_alloc>:
// Returns 0 on success, < 0 on error.  Errors are:
//	-E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
  801b8b:	55                   	push   %ebp
  801b8c:	89 e5                	mov    %esp,%ebp
  801b8e:	57                   	push   %edi
  801b8f:	56                   	push   %esi
  801b90:	53                   	push   %ebx
  801b91:	8b 7d 08             	mov    0x8(%ebp),%edi
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
		fd = INDEX2FD(i);
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
  801b94:	a1 00 dd 7b ef       	mov    0xef7bdd00,%eax
  801b99:	a8 01                	test   $0x1,%al
  801b9b:	74 36                	je     801bd3 <fd_alloc+0x48>
  801b9d:	a1 00 00 74 ef       	mov    0xef740000,%eax
  801ba2:	a8 01                	test   $0x1,%al
  801ba4:	74 2d                	je     801bd3 <fd_alloc+0x48>
  801ba6:	b8 00 10 00 d0       	mov    $0xd0001000,%eax
  801bab:	b9 00 d0 7b ef       	mov    $0xef7bd000,%ecx
  801bb0:	be 00 00 40 ef       	mov    $0xef400000,%esi
  801bb5:	89 c3                	mov    %eax,%ebx
  801bb7:	89 c2                	mov    %eax,%edx
  801bb9:	c1 ea 16             	shr    $0x16,%edx
  801bbc:	8b 14 91             	mov    (%ecx,%edx,4),%edx
  801bbf:	f6 c2 01             	test   $0x1,%dl
  801bc2:	74 14                	je     801bd8 <fd_alloc+0x4d>
  801bc4:	89 c2                	mov    %eax,%edx
  801bc6:	c1 ea 0c             	shr    $0xc,%edx
  801bc9:	8b 14 96             	mov    (%esi,%edx,4),%edx
  801bcc:	f6 c2 01             	test   $0x1,%dl
  801bcf:	75 10                	jne    801be1 <fd_alloc+0x56>
  801bd1:	eb 05                	jmp    801bd8 <fd_alloc+0x4d>
  801bd3:	bb 00 00 00 d0       	mov    $0xd0000000,%ebx
			*fd_store = fd;
  801bd8:	89 1f                	mov    %ebx,(%edi)
  801bda:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  801bdf:	eb 17                	jmp    801bf8 <fd_alloc+0x6d>
  801be1:	05 00 10 00 00       	add    $0x1000,%eax
fd_alloc(struct Fd **fd_store)
{
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
  801be6:	3d 00 00 02 d0       	cmp    $0xd0020000,%eax
  801beb:	75 c8                	jne    801bb5 <fd_alloc+0x2a>
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
			*fd_store = fd;
			return 0;
		}
	}
	*fd_store = 0;
  801bed:	c7 07 00 00 00 00    	movl   $0x0,(%edi)
  801bf3:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
	return -E_MAX_OPEN;
}
  801bf8:	5b                   	pop    %ebx
  801bf9:	5e                   	pop    %esi
  801bfa:	5f                   	pop    %edi
  801bfb:	5d                   	pop    %ebp
  801bfc:	c3                   	ret    

00801bfd <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
//	-E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
  801bfd:	55                   	push   %ebp
  801bfe:	89 e5                	mov    %esp,%ebp
	struct Fd *fd=NULL;

	if (fdnum < 0 || fdnum >= MAXFD) {
  801c00:	8b 45 08             	mov    0x8(%ebp),%eax
  801c03:	83 f8 1f             	cmp    $0x1f,%eax
  801c06:	77 36                	ja     801c3e <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] bad fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	fd = INDEX2FD(fdnum);
  801c08:	05 00 00 0d 00       	add    $0xd0000,%eax
  801c0d:	c1 e0 0c             	shl    $0xc,%eax
	if (!(vpd[PDX(fd)] & PTE_P) || !(vpt[VPN(fd)] & PTE_P)) {
  801c10:	89 c2                	mov    %eax,%edx
  801c12:	c1 ea 16             	shr    $0x16,%edx
  801c15:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  801c1c:	f6 c2 01             	test   $0x1,%dl
  801c1f:	74 1d                	je     801c3e <fd_lookup+0x41>
  801c21:	89 c2                	mov    %eax,%edx
  801c23:	c1 ea 0c             	shr    $0xc,%edx
  801c26:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  801c2d:	f6 c2 01             	test   $0x1,%dl
  801c30:	74 0c                	je     801c3e <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] closed fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	*fd_store = fd;
  801c32:	8b 55 0c             	mov    0xc(%ebp),%edx
  801c35:	89 02                	mov    %eax,(%edx)
  801c37:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
  801c3c:	eb 05                	jmp    801c43 <fd_lookup+0x46>
  801c3e:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801c43:	5d                   	pop    %ebp
  801c44:	c3                   	ret    

00801c45 <seek>:
	return (*dev->dev_write)(fd, buf, n);
}

int
seek(int fdnum, off_t offset)
{
  801c45:	55                   	push   %ebp
  801c46:	89 e5                	mov    %esp,%ebp
  801c48:	83 ec 18             	sub    $0x18,%esp
	int r;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  801c4b:	8d 45 fc             	lea    -0x4(%ebp),%eax
  801c4e:	89 44 24 04          	mov    %eax,0x4(%esp)
  801c52:	8b 45 08             	mov    0x8(%ebp),%eax
  801c55:	89 04 24             	mov    %eax,(%esp)
  801c58:	e8 a0 ff ff ff       	call   801bfd <fd_lookup>
  801c5d:	85 c0                	test   %eax,%eax
  801c5f:	78 0e                	js     801c6f <seek+0x2a>
		return r;
	fd->fd_offset = offset;
  801c61:	8b 45 fc             	mov    -0x4(%ebp),%eax
  801c64:	8b 55 0c             	mov    0xc(%ebp),%edx
  801c67:	89 50 04             	mov    %edx,0x4(%eax)
  801c6a:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  801c6f:	c9                   	leave  
  801c70:	c3                   	ret    

00801c71 <dev_lookup>:
	0
};

int
dev_lookup(int dev_id, struct Dev **dev)
{
  801c71:	55                   	push   %ebp
  801c72:	89 e5                	mov    %esp,%ebp
  801c74:	56                   	push   %esi
  801c75:	53                   	push   %ebx
  801c76:	83 ec 10             	sub    $0x10,%esp
  801c79:	8b 4d 08             	mov    0x8(%ebp),%ecx
  801c7c:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
  801c7f:	ba 00 00 00 00       	mov    $0x0,%edx
int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
  801c84:	b8 04 70 80 00       	mov    $0x807004,%eax
  801c89:	39 0d 04 70 80 00    	cmp    %ecx,0x807004
  801c8f:	75 11                	jne    801ca2 <dev_lookup+0x31>
  801c91:	eb 04                	jmp    801c97 <dev_lookup+0x26>
  801c93:	39 08                	cmp    %ecx,(%eax)
  801c95:	75 10                	jne    801ca7 <dev_lookup+0x36>
			*dev = devtab[i];
  801c97:	89 03                	mov    %eax,(%ebx)
  801c99:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  801c9e:	66 90                	xchg   %ax,%ax
  801ca0:	eb 36                	jmp    801cd8 <dev_lookup+0x67>

int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
  801ca2:	be e4 3c 80 00       	mov    $0x803ce4,%esi
  801ca7:	83 c2 01             	add    $0x1,%edx
  801caa:	8b 04 96             	mov    (%esi,%edx,4),%eax
  801cad:	85 c0                	test   %eax,%eax
  801caf:	75 e2                	jne    801c93 <dev_lookup+0x22>
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
		}
	cprintf("[%08x] unknown device type %d\n", env->env_id, dev_id);
  801cb1:	a1 8c 70 80 00       	mov    0x80708c,%eax
  801cb6:	8b 40 4c             	mov    0x4c(%eax),%eax
  801cb9:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  801cbd:	89 44 24 04          	mov    %eax,0x4(%esp)
  801cc1:	c7 04 24 68 3c 80 00 	movl   $0x803c68,(%esp)
  801cc8:	e8 74 ea ff ff       	call   800741 <cprintf>
	*dev = 0;
  801ccd:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  801cd3:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
	return -E_INVAL;
}
  801cd8:	83 c4 10             	add    $0x10,%esp
  801cdb:	5b                   	pop    %ebx
  801cdc:	5e                   	pop    %esi
  801cdd:	5d                   	pop    %ebp
  801cde:	c3                   	ret    

00801cdf <fstat>:
	return (*dev->dev_trunc)(fd, newsize);
}

int
fstat(int fdnum, struct Stat *stat)
{
  801cdf:	55                   	push   %ebp
  801ce0:	89 e5                	mov    %esp,%ebp
  801ce2:	53                   	push   %ebx
  801ce3:	83 ec 24             	sub    $0x24,%esp
  801ce6:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801ce9:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801cec:	89 44 24 04          	mov    %eax,0x4(%esp)
  801cf0:	8b 45 08             	mov    0x8(%ebp),%eax
  801cf3:	89 04 24             	mov    %eax,(%esp)
  801cf6:	e8 02 ff ff ff       	call   801bfd <fd_lookup>
  801cfb:	85 c0                	test   %eax,%eax
  801cfd:	78 53                	js     801d52 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801cff:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801d02:	89 44 24 04          	mov    %eax,0x4(%esp)
  801d06:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801d09:	8b 00                	mov    (%eax),%eax
  801d0b:	89 04 24             	mov    %eax,(%esp)
  801d0e:	e8 5e ff ff ff       	call   801c71 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801d13:	85 c0                	test   %eax,%eax
  801d15:	78 3b                	js     801d52 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if (!dev->dev_stat)
  801d17:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801d1c:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801d1f:	83 7a 14 00          	cmpl   $0x0,0x14(%edx)
  801d23:	74 2d                	je     801d52 <fstat+0x73>
		return -E_NOT_SUPP;
	stat->st_name[0] = 0;
  801d25:	c6 03 00             	movb   $0x0,(%ebx)
	stat->st_size = 0;
  801d28:	c7 83 80 00 00 00 00 	movl   $0x0,0x80(%ebx)
  801d2f:	00 00 00 
	stat->st_isdir = 0;
  801d32:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  801d39:	00 00 00 
	stat->st_dev = dev;
  801d3c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d3f:	89 83 88 00 00 00    	mov    %eax,0x88(%ebx)
	return (*dev->dev_stat)(fd, stat);
  801d45:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801d49:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801d4c:	89 14 24             	mov    %edx,(%esp)
  801d4f:	ff 50 14             	call   *0x14(%eax)
}
  801d52:	83 c4 24             	add    $0x24,%esp
  801d55:	5b                   	pop    %ebx
  801d56:	5d                   	pop    %ebp
  801d57:	c3                   	ret    

00801d58 <ftruncate>:
	return 0;
}

int
ftruncate(int fdnum, off_t newsize)
{
  801d58:	55                   	push   %ebp
  801d59:	89 e5                	mov    %esp,%ebp
  801d5b:	53                   	push   %ebx
  801d5c:	83 ec 24             	sub    $0x24,%esp
  801d5f:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801d62:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801d65:	89 44 24 04          	mov    %eax,0x4(%esp)
  801d69:	89 1c 24             	mov    %ebx,(%esp)
  801d6c:	e8 8c fe ff ff       	call   801bfd <fd_lookup>
  801d71:	85 c0                	test   %eax,%eax
  801d73:	78 5f                	js     801dd4 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801d75:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801d78:	89 44 24 04          	mov    %eax,0x4(%esp)
  801d7c:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801d7f:	8b 00                	mov    (%eax),%eax
  801d81:	89 04 24             	mov    %eax,(%esp)
  801d84:	e8 e8 fe ff ff       	call   801c71 <dev_lookup>
ftruncate(int fdnum, off_t newsize)
{
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801d89:	85 c0                	test   %eax,%eax
  801d8b:	78 47                	js     801dd4 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  801d8d:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801d90:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  801d94:	75 23                	jne    801db9 <ftruncate+0x61>
		cprintf("[%08x] ftruncate %d -- bad mode\n",
			env->env_id, fdnum); 
  801d96:	a1 8c 70 80 00       	mov    0x80708c,%eax
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
		cprintf("[%08x] ftruncate %d -- bad mode\n",
  801d9b:	8b 40 4c             	mov    0x4c(%eax),%eax
  801d9e:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801da2:	89 44 24 04          	mov    %eax,0x4(%esp)
  801da6:	c7 04 24 88 3c 80 00 	movl   $0x803c88,(%esp)
  801dad:	e8 8f e9 ff ff       	call   800741 <cprintf>
  801db2:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
			env->env_id, fdnum); 
		return -E_INVAL;
  801db7:	eb 1b                	jmp    801dd4 <ftruncate+0x7c>
	}
	if (!dev->dev_trunc)
  801db9:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801dbc:	8b 48 18             	mov    0x18(%eax),%ecx
  801dbf:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801dc4:	85 c9                	test   %ecx,%ecx
  801dc6:	74 0c                	je     801dd4 <ftruncate+0x7c>
		return -E_NOT_SUPP;
	return (*dev->dev_trunc)(fd, newsize);
  801dc8:	8b 45 0c             	mov    0xc(%ebp),%eax
  801dcb:	89 44 24 04          	mov    %eax,0x4(%esp)
  801dcf:	89 14 24             	mov    %edx,(%esp)
  801dd2:	ff d1                	call   *%ecx
}
  801dd4:	83 c4 24             	add    $0x24,%esp
  801dd7:	5b                   	pop    %ebx
  801dd8:	5d                   	pop    %ebp
  801dd9:	c3                   	ret    

00801dda <write>:
	return tot;
}

ssize_t
write(int fdnum, const void *buf, size_t n)
{
  801dda:	55                   	push   %ebp
  801ddb:	89 e5                	mov    %esp,%ebp
  801ddd:	53                   	push   %ebx
  801dde:	83 ec 24             	sub    $0x24,%esp
  801de1:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801de4:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801de7:	89 44 24 04          	mov    %eax,0x4(%esp)
  801deb:	89 1c 24             	mov    %ebx,(%esp)
  801dee:	e8 0a fe ff ff       	call   801bfd <fd_lookup>
  801df3:	85 c0                	test   %eax,%eax
  801df5:	78 66                	js     801e5d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801df7:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801dfa:	89 44 24 04          	mov    %eax,0x4(%esp)
  801dfe:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801e01:	8b 00                	mov    (%eax),%eax
  801e03:	89 04 24             	mov    %eax,(%esp)
  801e06:	e8 66 fe ff ff       	call   801c71 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801e0b:	85 c0                	test   %eax,%eax
  801e0d:	78 4e                	js     801e5d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  801e0f:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801e12:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  801e16:	75 23                	jne    801e3b <write+0x61>
		cprintf("[%08x] write %d -- bad mode\n", env->env_id, fdnum);
  801e18:	a1 8c 70 80 00       	mov    0x80708c,%eax
  801e1d:	8b 40 4c             	mov    0x4c(%eax),%eax
  801e20:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801e24:	89 44 24 04          	mov    %eax,0x4(%esp)
  801e28:	c7 04 24 a9 3c 80 00 	movl   $0x803ca9,(%esp)
  801e2f:	e8 0d e9 ff ff       	call   800741 <cprintf>
  801e34:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  801e39:	eb 22                	jmp    801e5d <write+0x83>
	}
	if (debug)
		cprintf("write %d %p %d via dev %s\n",
			fdnum, buf, n, dev->dev_name);
	if (!dev->dev_write)
  801e3b:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801e3e:	8b 48 0c             	mov    0xc(%eax),%ecx
  801e41:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801e46:	85 c9                	test   %ecx,%ecx
  801e48:	74 13                	je     801e5d <write+0x83>
		return -E_NOT_SUPP;
	return (*dev->dev_write)(fd, buf, n);
  801e4a:	8b 45 10             	mov    0x10(%ebp),%eax
  801e4d:	89 44 24 08          	mov    %eax,0x8(%esp)
  801e51:	8b 45 0c             	mov    0xc(%ebp),%eax
  801e54:	89 44 24 04          	mov    %eax,0x4(%esp)
  801e58:	89 14 24             	mov    %edx,(%esp)
  801e5b:	ff d1                	call   *%ecx
}
  801e5d:	83 c4 24             	add    $0x24,%esp
  801e60:	5b                   	pop    %ebx
  801e61:	5d                   	pop    %ebp
  801e62:	c3                   	ret    

00801e63 <read>:
	return r;
}

ssize_t
read(int fdnum, void *buf, size_t n)
{
  801e63:	55                   	push   %ebp
  801e64:	89 e5                	mov    %esp,%ebp
  801e66:	57                   	push   %edi
  801e67:	56                   	push   %esi
  801e68:	53                   	push   %ebx
  801e69:	83 ec 2c             	sub    $0x2c,%esp
  801e6c:	8b 5d 08             	mov    0x8(%ebp),%ebx
  801e6f:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801e72:	8d 45 e0             	lea    -0x20(%ebp),%eax
  801e75:	89 44 24 04          	mov    %eax,0x4(%esp)
  801e79:	89 1c 24             	mov    %ebx,(%esp)
  801e7c:	e8 7c fd ff ff       	call   801bfd <fd_lookup>
  801e81:	85 c0                	test   %eax,%eax
  801e83:	0f 88 b0 00 00 00    	js     801f39 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801e89:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801e8c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801e90:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801e93:	8b 00                	mov    (%eax),%eax
  801e95:	89 04 24             	mov    %eax,(%esp)
  801e98:	e8 d4 fd ff ff       	call   801c71 <dev_lookup>
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801e9d:	85 c0                	test   %eax,%eax
  801e9f:	0f 88 94 00 00 00    	js     801f39 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
  801ea5:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801ea8:	8b 40 08             	mov    0x8(%eax),%eax
  801eab:	83 e0 03             	and    $0x3,%eax
  801eae:	83 f8 01             	cmp    $0x1,%eax
  801eb1:	75 23                	jne    801ed6 <read+0x73>
		cprintf("[%08x] read %d -- bad mode\n", env->env_id, fdnum); 
  801eb3:	a1 8c 70 80 00       	mov    0x80708c,%eax
  801eb8:	8b 40 4c             	mov    0x4c(%eax),%eax
  801ebb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801ebf:	89 44 24 04          	mov    %eax,0x4(%esp)
  801ec3:	c7 04 24 c6 3c 80 00 	movl   $0x803cc6,(%esp)
  801eca:	e8 72 e8 ff ff       	call   800741 <cprintf>
  801ecf:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  801ed4:	eb 63                	jmp    801f39 <read+0xd6>
	}
	if (!dev->dev_read)
  801ed6:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801edb:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  801ede:	83 7a 08 00          	cmpl   $0x0,0x8(%edx)
  801ee2:	74 55                	je     801f39 <read+0xd6>
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  801ee4:	ba 00 00 00 00       	mov    $0x0,%edx
  801ee9:	bb 00 00 00 00       	mov    $0x0,%ebx
  801eee:	b8 00 00 00 00       	mov    $0x0,%eax
  801ef3:	85 f6                	test   %esi,%esi
  801ef5:	74 42                	je     801f39 <read+0xd6>
    int count=0;
    if ((n-tot)/PGSIZE == 0)
  801ef7:	bf 00 10 00 00       	mov    $0x1000,%edi
  801efc:	89 f0                	mov    %esi,%eax
  801efe:	29 d0                	sub    %edx,%eax
  801f00:	89 c1                	mov    %eax,%ecx
  801f02:	81 e1 ff 0f 00 00    	and    $0xfff,%ecx
  801f08:	3d 00 10 00 00       	cmp    $0x1000,%eax
  801f0d:	0f 43 cf             	cmovae %edi,%ecx
      count = (n-tot)%PGSIZE;
    else
      count = PGSIZE;

	  m = (*dev->dev_read)(fd, (char *)buf + tot, count);
  801f10:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  801f14:	03 55 0c             	add    0xc(%ebp),%edx
  801f17:	89 54 24 04          	mov    %edx,0x4(%esp)
  801f1b:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801f1e:	89 04 24             	mov    %eax,(%esp)
  801f21:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801f24:	ff 50 08             	call   *0x8(%eax)
		if (m < 0)
  801f27:	85 c0                	test   %eax,%eax
  801f29:	78 0e                	js     801f39 <read+0xd6>
			return m;
		if (m == 0)
  801f2b:	85 c0                	test   %eax,%eax
  801f2d:	74 08                	je     801f37 <read+0xd4>
		return -E_INVAL;
	}
	if (!dev->dev_read)
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  801f2f:	01 c3                	add    %eax,%ebx
  801f31:	89 da                	mov    %ebx,%edx
  801f33:	39 f3                	cmp    %esi,%ebx
  801f35:	72 c5                	jb     801efc <read+0x99>
  801f37:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  801f39:	83 c4 2c             	add    $0x2c,%esp
  801f3c:	5b                   	pop    %ebx
  801f3d:	5e                   	pop    %esi
  801f3e:	5f                   	pop    %edi
  801f3f:	5d                   	pop    %ebp
  801f40:	c3                   	ret    

00801f41 <readn>:

ssize_t
readn(int fdnum, void *buf, size_t n)
{
  801f41:	55                   	push   %ebp
  801f42:	89 e5                	mov    %esp,%ebp
  801f44:	57                   	push   %edi
  801f45:	56                   	push   %esi
  801f46:	53                   	push   %ebx
  801f47:	83 ec 1c             	sub    $0x1c,%esp
  801f4a:	8b 7d 08             	mov    0x8(%ebp),%edi
  801f4d:	8b 75 10             	mov    0x10(%ebp),%esi
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801f50:	ba 00 00 00 00       	mov    $0x0,%edx
  801f55:	bb 00 00 00 00       	mov    $0x0,%ebx
  801f5a:	b8 00 00 00 00       	mov    $0x0,%eax
  801f5f:	85 f6                	test   %esi,%esi
  801f61:	74 29                	je     801f8c <readn+0x4b>
		m = read(fdnum, (char*)buf + tot, n - tot);
  801f63:	89 f0                	mov    %esi,%eax
  801f65:	29 d0                	sub    %edx,%eax
  801f67:	89 44 24 08          	mov    %eax,0x8(%esp)
  801f6b:	03 55 0c             	add    0xc(%ebp),%edx
  801f6e:	89 54 24 04          	mov    %edx,0x4(%esp)
  801f72:	89 3c 24             	mov    %edi,(%esp)
  801f75:	e8 e9 fe ff ff       	call   801e63 <read>
		if (m < 0)
  801f7a:	85 c0                	test   %eax,%eax
  801f7c:	78 0e                	js     801f8c <readn+0x4b>
			return m;
		if (m == 0)
  801f7e:	85 c0                	test   %eax,%eax
  801f80:	74 08                	je     801f8a <readn+0x49>
readn(int fdnum, void *buf, size_t n)
{
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801f82:	01 c3                	add    %eax,%ebx
  801f84:	89 da                	mov    %ebx,%edx
  801f86:	39 f3                	cmp    %esi,%ebx
  801f88:	72 d9                	jb     801f63 <readn+0x22>
  801f8a:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  801f8c:	83 c4 1c             	add    $0x1c,%esp
  801f8f:	5b                   	pop    %ebx
  801f90:	5e                   	pop    %esi
  801f91:	5f                   	pop    %edi
  801f92:	5d                   	pop    %ebp
  801f93:	c3                   	ret    

00801f94 <fd_close>:
// If 'must_exist' is 1, then fd_close returns -E_INVAL when passed a
// closed or nonexistent file descriptor.
// Returns 0 on success, < 0 on error.
int
fd_close(struct Fd *fd, bool must_exist)
{
  801f94:	55                   	push   %ebp
  801f95:	89 e5                	mov    %esp,%ebp
  801f97:	83 ec 28             	sub    $0x28,%esp
  801f9a:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801f9d:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801fa0:	8b 75 08             	mov    0x8(%ebp),%esi
	struct Fd *fd2;
	struct Dev *dev;
	int r;
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  801fa3:	89 34 24             	mov    %esi,(%esp)
  801fa6:	e8 b5 fb ff ff       	call   801b60 <fd2num>
  801fab:	8d 55 f4             	lea    -0xc(%ebp),%edx
  801fae:	89 54 24 04          	mov    %edx,0x4(%esp)
  801fb2:	89 04 24             	mov    %eax,(%esp)
  801fb5:	e8 43 fc ff ff       	call   801bfd <fd_lookup>
  801fba:	89 c3                	mov    %eax,%ebx
  801fbc:	85 c0                	test   %eax,%eax
  801fbe:	78 05                	js     801fc5 <fd_close+0x31>
  801fc0:	3b 75 f4             	cmp    -0xc(%ebp),%esi
  801fc3:	74 0e                	je     801fd3 <fd_close+0x3f>
	    || fd != fd2)
		return (must_exist ? r : 0);
  801fc5:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  801fc9:	b8 00 00 00 00       	mov    $0x0,%eax
  801fce:	0f 44 d8             	cmove  %eax,%ebx
  801fd1:	eb 3d                	jmp    802010 <fd_close+0x7c>
	if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
  801fd3:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801fd6:	89 44 24 04          	mov    %eax,0x4(%esp)
  801fda:	8b 06                	mov    (%esi),%eax
  801fdc:	89 04 24             	mov    %eax,(%esp)
  801fdf:	e8 8d fc ff ff       	call   801c71 <dev_lookup>
  801fe4:	89 c3                	mov    %eax,%ebx
  801fe6:	85 c0                	test   %eax,%eax
  801fe8:	78 16                	js     802000 <fd_close+0x6c>
		if (dev->dev_close)
  801fea:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801fed:	8b 40 10             	mov    0x10(%eax),%eax
  801ff0:	bb 00 00 00 00       	mov    $0x0,%ebx
  801ff5:	85 c0                	test   %eax,%eax
  801ff7:	74 07                	je     802000 <fd_close+0x6c>
			r = (*dev->dev_close)(fd);
  801ff9:	89 34 24             	mov    %esi,(%esp)
  801ffc:	ff d0                	call   *%eax
  801ffe:	89 c3                	mov    %eax,%ebx
		else
			r = 0;
	}
	// Make sure fd is unmapped.  Might be a no-op if
	// (*dev->dev_close)(fd) already unmapped it.
	(void) sys_page_unmap(0, fd);
  802000:	89 74 24 04          	mov    %esi,0x4(%esp)
  802004:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80200b:	e8 9a f4 ff ff       	call   8014aa <sys_page_unmap>
	return r;
}
  802010:	89 d8                	mov    %ebx,%eax
  802012:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  802015:	8b 75 fc             	mov    -0x4(%ebp),%esi
  802018:	89 ec                	mov    %ebp,%esp
  80201a:	5d                   	pop    %ebp
  80201b:	c3                   	ret    

0080201c <close>:
	return -E_INVAL;
}

int
close(int fdnum)
{
  80201c:	55                   	push   %ebp
  80201d:	89 e5                	mov    %esp,%ebp
  80201f:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  802022:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802025:	89 44 24 04          	mov    %eax,0x4(%esp)
  802029:	8b 45 08             	mov    0x8(%ebp),%eax
  80202c:	89 04 24             	mov    %eax,(%esp)
  80202f:	e8 c9 fb ff ff       	call   801bfd <fd_lookup>
  802034:	85 c0                	test   %eax,%eax
  802036:	78 13                	js     80204b <close+0x2f>
		return r;
	else
		return fd_close(fd, 1);
  802038:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  80203f:	00 
  802040:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802043:	89 04 24             	mov    %eax,(%esp)
  802046:	e8 49 ff ff ff       	call   801f94 <fd_close>
}
  80204b:	c9                   	leave  
  80204c:	c3                   	ret    

0080204d <stat>:
	return (*dev->dev_stat)(fd, stat);
}

int
stat(const char *path, struct Stat *stat)
{
  80204d:	55                   	push   %ebp
  80204e:	89 e5                	mov    %esp,%ebp
  802050:	83 ec 18             	sub    $0x18,%esp
  802053:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802056:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int fd, r;

	if ((fd = open(path, O_RDONLY)) < 0)
  802059:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  802060:	00 
  802061:	8b 45 08             	mov    0x8(%ebp),%eax
  802064:	89 04 24             	mov    %eax,(%esp)
  802067:	e8 80 03 00 00       	call   8023ec <open>
  80206c:	89 c3                	mov    %eax,%ebx
  80206e:	85 c0                	test   %eax,%eax
  802070:	78 1b                	js     80208d <stat+0x40>
		return fd;
	r = fstat(fd, stat);
  802072:	8b 45 0c             	mov    0xc(%ebp),%eax
  802075:	89 44 24 04          	mov    %eax,0x4(%esp)
  802079:	89 1c 24             	mov    %ebx,(%esp)
  80207c:	e8 5e fc ff ff       	call   801cdf <fstat>
  802081:	89 c6                	mov    %eax,%esi
	close(fd);
  802083:	89 1c 24             	mov    %ebx,(%esp)
  802086:	e8 91 ff ff ff       	call   80201c <close>
  80208b:	89 f3                	mov    %esi,%ebx
	return r;
}
  80208d:	89 d8                	mov    %ebx,%eax
  80208f:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  802092:	8b 75 fc             	mov    -0x4(%ebp),%esi
  802095:	89 ec                	mov    %ebp,%esp
  802097:	5d                   	pop    %ebp
  802098:	c3                   	ret    

00802099 <close_all>:
		return fd_close(fd, 1);
}

void
close_all(void)
{
  802099:	55                   	push   %ebp
  80209a:	89 e5                	mov    %esp,%ebp
  80209c:	53                   	push   %ebx
  80209d:	83 ec 14             	sub    $0x14,%esp
  8020a0:	bb 00 00 00 00       	mov    $0x0,%ebx
	int i;
	for (i = 0; i < MAXFD; i++)
		close(i);
  8020a5:	89 1c 24             	mov    %ebx,(%esp)
  8020a8:	e8 6f ff ff ff       	call   80201c <close>

void
close_all(void)
{
	int i;
	for (i = 0; i < MAXFD; i++)
  8020ad:	83 c3 01             	add    $0x1,%ebx
  8020b0:	83 fb 20             	cmp    $0x20,%ebx
  8020b3:	75 f0                	jne    8020a5 <close_all+0xc>
		close(i);
}
  8020b5:	83 c4 14             	add    $0x14,%esp
  8020b8:	5b                   	pop    %ebx
  8020b9:	5d                   	pop    %ebp
  8020ba:	c3                   	ret    

008020bb <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
  8020bb:	55                   	push   %ebp
  8020bc:	89 e5                	mov    %esp,%ebp
  8020be:	83 ec 58             	sub    $0x58,%esp
  8020c1:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8020c4:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8020c7:	89 7d fc             	mov    %edi,-0x4(%ebp)
  8020ca:	8b 7d 0c             	mov    0xc(%ebp),%edi
	int r;
	char *ova, *nva;
	pte_t pte;
	struct Fd *oldfd, *newfd;

	if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
  8020cd:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  8020d0:	89 44 24 04          	mov    %eax,0x4(%esp)
  8020d4:	8b 45 08             	mov    0x8(%ebp),%eax
  8020d7:	89 04 24             	mov    %eax,(%esp)
  8020da:	e8 1e fb ff ff       	call   801bfd <fd_lookup>
  8020df:	89 c3                	mov    %eax,%ebx
  8020e1:	85 c0                	test   %eax,%eax
  8020e3:	0f 88 e0 00 00 00    	js     8021c9 <dup+0x10e>
		return r;
	close(newfdnum);
  8020e9:	89 3c 24             	mov    %edi,(%esp)
  8020ec:	e8 2b ff ff ff       	call   80201c <close>

	newfd = INDEX2FD(newfdnum);
  8020f1:	8d b7 00 00 0d 00    	lea    0xd0000(%edi),%esi
  8020f7:	c1 e6 0c             	shl    $0xc,%esi
	ova = fd2data(oldfd);
  8020fa:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8020fd:	89 04 24             	mov    %eax,(%esp)
  802100:	e8 6b fa ff ff       	call   801b70 <fd2data>
  802105:	89 c3                	mov    %eax,%ebx
	nva = fd2data(newfd);
  802107:	89 34 24             	mov    %esi,(%esp)
  80210a:	e8 61 fa ff ff       	call   801b70 <fd2data>
  80210f:	89 45 d4             	mov    %eax,-0x2c(%ebp)
	if ((vpd[PDX(ova)] & PTE_P) && (vpt[VPN(ova)] & PTE_P))
  802112:	89 da                	mov    %ebx,%edx
  802114:	89 d8                	mov    %ebx,%eax
  802116:	c1 e8 16             	shr    $0x16,%eax
  802119:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  802120:	a8 01                	test   $0x1,%al
  802122:	74 43                	je     802167 <dup+0xac>
  802124:	c1 ea 0c             	shr    $0xc,%edx
  802127:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  80212e:	a8 01                	test   $0x1,%al
  802130:	74 35                	je     802167 <dup+0xac>
		if ((r = sys_page_map(0, ova, 0, nva, (vpt[VPN(ova)]) & PTE_USER)) < 0)
  802132:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  802139:	25 07 0e 00 00       	and    $0xe07,%eax
  80213e:	89 44 24 10          	mov    %eax,0x10(%esp)
  802142:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  802145:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802149:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  802150:	00 
  802151:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802155:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80215c:	e8 a7 f3 ff ff       	call   801508 <sys_page_map>
  802161:	89 c3                	mov    %eax,%ebx
  802163:	85 c0                	test   %eax,%eax
  802165:	78 3f                	js     8021a6 <dup+0xeb>
			goto err;
	if ((r = sys_page_map(0, oldfd, 0, newfd, (vpt[VPN(oldfd)]) & PTE_USER)) < 0)
  802167:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80216a:	89 c2                	mov    %eax,%edx
  80216c:	c1 ea 0c             	shr    $0xc,%edx
  80216f:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  802176:	81 e2 07 0e 00 00    	and    $0xe07,%edx
  80217c:	89 54 24 10          	mov    %edx,0x10(%esp)
  802180:	89 74 24 0c          	mov    %esi,0xc(%esp)
  802184:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80218b:	00 
  80218c:	89 44 24 04          	mov    %eax,0x4(%esp)
  802190:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802197:	e8 6c f3 ff ff       	call   801508 <sys_page_map>
  80219c:	89 c3                	mov    %eax,%ebx
  80219e:	85 c0                	test   %eax,%eax
  8021a0:	78 04                	js     8021a6 <dup+0xeb>
  8021a2:	89 fb                	mov    %edi,%ebx
  8021a4:	eb 23                	jmp    8021c9 <dup+0x10e>
		goto err;

	return newfdnum;
err:
	sys_page_unmap(0, newfd);
  8021a6:	89 74 24 04          	mov    %esi,0x4(%esp)
  8021aa:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8021b1:	e8 f4 f2 ff ff       	call   8014aa <sys_page_unmap>
	sys_page_unmap(0, nva);
  8021b6:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  8021b9:	89 44 24 04          	mov    %eax,0x4(%esp)
  8021bd:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8021c4:	e8 e1 f2 ff ff       	call   8014aa <sys_page_unmap>
	return r;
}
  8021c9:	89 d8                	mov    %ebx,%eax
  8021cb:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8021ce:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8021d1:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8021d4:	89 ec                	mov    %ebp,%esp
  8021d6:	5d                   	pop    %ebp
  8021d7:	c3                   	ret    

008021d8 <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
  8021d8:	55                   	push   %ebp
  8021d9:	89 e5                	mov    %esp,%ebp
  8021db:	53                   	push   %ebx
  8021dc:	83 ec 14             	sub    $0x14,%esp
  8021df:	89 d3                	mov    %edx,%ebx
	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", env->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(envs[1].env_id, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
  8021e1:	8b 15 c8 00 c0 ee    	mov    0xeec000c8,%edx
  8021e7:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  8021ee:	00 
  8021ef:	c7 44 24 08 00 40 80 	movl   $0x804000,0x8(%esp)
  8021f6:	00 
  8021f7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8021fb:	89 14 24             	mov    %edx,(%esp)
  8021fe:	e8 8d f8 ff ff       	call   801a90 <ipc_send>
	return ipc_recv(NULL, dstva, NULL);
  802203:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80220a:	00 
  80220b:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80220f:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802216:	e8 e7 f8 ff ff       	call   801b02 <ipc_recv>
}
  80221b:	83 c4 14             	add    $0x14,%esp
  80221e:	5b                   	pop    %ebx
  80221f:	5d                   	pop    %ebp
  802220:	c3                   	ret    

00802221 <devfile_trunc>:
}

// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
  802221:	55                   	push   %ebp
  802222:	89 e5                	mov    %esp,%ebp
  802224:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.set_size.req_fileid = fd->fd_file.id;
  802227:	8b 45 08             	mov    0x8(%ebp),%eax
  80222a:	8b 40 0c             	mov    0xc(%eax),%eax
  80222d:	a3 00 40 80 00       	mov    %eax,0x804000
	fsipcbuf.set_size.req_size = newsize;
  802232:	8b 45 0c             	mov    0xc(%ebp),%eax
  802235:	a3 04 40 80 00       	mov    %eax,0x804004
	return fsipc(FSREQ_SET_SIZE, NULL);
  80223a:	ba 00 00 00 00       	mov    $0x0,%edx
  80223f:	b8 02 00 00 00       	mov    $0x2,%eax
  802244:	e8 8f ff ff ff       	call   8021d8 <fsipc>
}
  802249:	c9                   	leave  
  80224a:	c3                   	ret    

0080224b <devfile_flush>:
// open, unmapping it is enough to free up server-side resources.
// Other than that, we just have to make sure our changes are flushed
// to disk.
static int
devfile_flush(struct Fd *fd)
{
  80224b:	55                   	push   %ebp
  80224c:	89 e5                	mov    %esp,%ebp
  80224e:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.flush.req_fileid = fd->fd_file.id;
  802251:	8b 45 08             	mov    0x8(%ebp),%eax
  802254:	8b 40 0c             	mov    0xc(%eax),%eax
  802257:	a3 00 40 80 00       	mov    %eax,0x804000
	return fsipc(FSREQ_FLUSH, NULL);
  80225c:	ba 00 00 00 00       	mov    $0x0,%edx
  802261:	b8 06 00 00 00       	mov    $0x6,%eax
  802266:	e8 6d ff ff ff       	call   8021d8 <fsipc>
}
  80226b:	c9                   	leave  
  80226c:	c3                   	ret    

0080226d <sync>:
}

// Synchronize disk with buffer cache
int
sync(void)
{
  80226d:	55                   	push   %ebp
  80226e:	89 e5                	mov    %esp,%ebp
  802270:	83 ec 08             	sub    $0x8,%esp
	// Ask the file server to update the disk
	// by writing any dirty blocks in the buffer cache.

	return fsipc(FSREQ_SYNC, NULL);
  802273:	ba 00 00 00 00       	mov    $0x0,%edx
  802278:	b8 08 00 00 00       	mov    $0x8,%eax
  80227d:	e8 56 ff ff ff       	call   8021d8 <fsipc>
}
  802282:	c9                   	leave  
  802283:	c3                   	ret    

00802284 <devfile_stat>:
    return n;
}

static int
devfile_stat(struct Fd *fd, struct Stat *st)
{
  802284:	55                   	push   %ebp
  802285:	89 e5                	mov    %esp,%ebp
  802287:	53                   	push   %ebx
  802288:	83 ec 14             	sub    $0x14,%esp
  80228b:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;

	fsipcbuf.stat.req_fileid = fd->fd_file.id;
  80228e:	8b 45 08             	mov    0x8(%ebp),%eax
  802291:	8b 40 0c             	mov    0xc(%eax),%eax
  802294:	a3 00 40 80 00       	mov    %eax,0x804000
	if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
  802299:	ba 00 00 00 00       	mov    $0x0,%edx
  80229e:	b8 05 00 00 00       	mov    $0x5,%eax
  8022a3:	e8 30 ff ff ff       	call   8021d8 <fsipc>
  8022a8:	85 c0                	test   %eax,%eax
  8022aa:	78 2b                	js     8022d7 <devfile_stat+0x53>
		return r;
	strcpy(st->st_name, fsipcbuf.statRet.ret_name);
  8022ac:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  8022b3:	00 
  8022b4:	89 1c 24             	mov    %ebx,(%esp)
  8022b7:	e8 4e eb ff ff       	call   800e0a <strcpy>
	st->st_size = fsipcbuf.statRet.ret_size;
  8022bc:	a1 80 40 80 00       	mov    0x804080,%eax
  8022c1:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	st->st_isdir = fsipcbuf.statRet.ret_isdir;
  8022c7:	a1 84 40 80 00       	mov    0x804084,%eax
  8022cc:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
  8022d2:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  8022d7:	83 c4 14             	add    $0x14,%esp
  8022da:	5b                   	pop    %ebx
  8022db:	5d                   	pop    %ebp
  8022dc:	c3                   	ret    

008022dd <devfile_write>:
// Returns:
//	 The number of bytes successfully written.
//	 < 0 on error.
static ssize_t
devfile_write(struct Fd *fd, const void *buf, size_t n)
{
  8022dd:	55                   	push   %ebp
  8022de:	89 e5                	mov    %esp,%ebp
  8022e0:	53                   	push   %ebx
  8022e1:	83 ec 14             	sub    $0x14,%esp
  8022e4:	8b 45 08             	mov    0x8(%ebp),%eax
  8022e7:	8b 55 0c             	mov    0xc(%ebp),%edx
  8022ea:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// careful: fsipcbuf.write.req_buf is only so large, but
	// remember that write is always allowed to write *fewer*
	// bytes than requested.
	// LAB 5: Your code here
    int r;
    if (!fd || !buf || (n>(PGSIZE-sizeof(size_t)-sizeof(int))))
  8022ed:	85 c0                	test   %eax,%eax
  8022ef:	74 44                	je     802335 <devfile_write+0x58>
  8022f1:	85 d2                	test   %edx,%edx
  8022f3:	74 40                	je     802335 <devfile_write+0x58>
  8022f5:	81 fb f8 0f 00 00    	cmp    $0xff8,%ebx
  8022fb:	77 38                	ja     802335 <devfile_write+0x58>
        return -E_INVAL;

    fsipcbuf.write.req_fileid   = fd->fd_file.id;
  8022fd:	8b 40 0c             	mov    0xc(%eax),%eax
  802300:	a3 00 40 80 00       	mov    %eax,0x804000
    fsipcbuf.write.req_n        = n;
  802305:	89 1d 04 40 80 00    	mov    %ebx,0x804004
    memmove(fsipcbuf.write.req_buf, buf, n);
  80230b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  80230f:	89 54 24 04          	mov    %edx,0x4(%esp)
  802313:	c7 04 24 08 40 80 00 	movl   $0x804008,(%esp)
  80231a:	e8 a6 ec ff ff       	call   800fc5 <memmove>
    if ((r=fsipc(FSREQ_WRITE, NULL))<0)
  80231f:	ba 00 00 00 00       	mov    $0x0,%edx
  802324:	b8 04 00 00 00       	mov    $0x4,%eax
  802329:	e8 aa fe ff ff       	call   8021d8 <fsipc>
        return r;
    return n;
  80232e:	85 c0                	test   %eax,%eax
  802330:	0f 49 c3             	cmovns %ebx,%eax
  802333:	eb 05                	jmp    80233a <devfile_write+0x5d>
  802335:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  80233a:	83 c4 14             	add    $0x14,%esp
  80233d:	5b                   	pop    %ebx
  80233e:	5d                   	pop    %ebp
  80233f:	c3                   	ret    

00802340 <devfile_read>:
// Returns:
// 	The number of bytes successfully read.
// 	< 0 on error.
static ssize_t
devfile_read(struct Fd *fd, void *buf, size_t n)
{
  802340:	55                   	push   %ebp
  802341:	89 e5                	mov    %esp,%ebp
  802343:	83 ec 18             	sub    $0x18,%esp
  802346:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802349:	89 75 fc             	mov    %esi,-0x4(%ebp)
  80234c:	8b 45 08             	mov    0x8(%ebp),%eax
  80234f:	8b 75 0c             	mov    0xc(%ebp),%esi
	// filling fsipcbuf.read with the request arguments.  The
	// bytes read will be written back to fsipcbuf by the file
	// system server.
	// LAB 5: Your code here
  int r;
  if (!fd || !buf)
  802352:	85 c0                	test   %eax,%eax
  802354:	74 04                	je     80235a <devfile_read+0x1a>
  802356:	85 f6                	test   %esi,%esi
  802358:	75 07                	jne    802361 <devfile_read+0x21>
  80235a:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  80235f:	eb 39                	jmp    80239a <devfile_read+0x5a>
    return -E_INVAL;

  fsipcbuf.read.req_fileid    = fd->fd_file.id;
  802361:	8b 40 0c             	mov    0xc(%eax),%eax
  802364:	a3 00 40 80 00       	mov    %eax,0x804000
  fsipcbuf.read.req_n         = n;
  802369:	8b 45 10             	mov    0x10(%ebp),%eax
  80236c:	a3 04 40 80 00       	mov    %eax,0x804004
  if ((r=fsipc(FSREQ_READ, NULL))<0)
  802371:	ba 00 00 00 00       	mov    $0x0,%edx
  802376:	b8 03 00 00 00       	mov    $0x3,%eax
  80237b:	e8 58 fe ff ff       	call   8021d8 <fsipc>
  802380:	89 c3                	mov    %eax,%ebx
  802382:	85 c0                	test   %eax,%eax
  802384:	78 14                	js     80239a <devfile_read+0x5a>
    return r;

  memmove(buf, fsipcbuf.readRet.ret_buf, r);
  802386:	89 44 24 08          	mov    %eax,0x8(%esp)
  80238a:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  802391:	00 
  802392:	89 34 24             	mov    %esi,(%esp)
  802395:	e8 2b ec ff ff       	call   800fc5 <memmove>
  return r;
}
  80239a:	89 d8                	mov    %ebx,%eax
  80239c:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80239f:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8023a2:	89 ec                	mov    %ebp,%esp
  8023a4:	5d                   	pop    %ebp
  8023a5:	c3                   	ret    

008023a6 <remove>:
}

// Delete a file
int
remove(const char *path)
{
  8023a6:	55                   	push   %ebp
  8023a7:	89 e5                	mov    %esp,%ebp
  8023a9:	53                   	push   %ebx
  8023aa:	83 ec 14             	sub    $0x14,%esp
  8023ad:	8b 5d 08             	mov    0x8(%ebp),%ebx
	if (strlen(path) >= MAXPATHLEN)
  8023b0:	89 1c 24             	mov    %ebx,(%esp)
  8023b3:	e8 08 ea ff ff       	call   800dc0 <strlen>
  8023b8:	89 c2                	mov    %eax,%edx
  8023ba:	b8 f4 ff ff ff       	mov    $0xfffffff4,%eax
  8023bf:	81 fa ff 03 00 00    	cmp    $0x3ff,%edx
  8023c5:	7f 1f                	jg     8023e6 <remove+0x40>
		return -E_BAD_PATH;
	strcpy(fsipcbuf.remove.req_path, path);
  8023c7:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8023cb:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  8023d2:	e8 33 ea ff ff       	call   800e0a <strcpy>
	return fsipc(FSREQ_REMOVE, NULL);
  8023d7:	ba 00 00 00 00       	mov    $0x0,%edx
  8023dc:	b8 07 00 00 00       	mov    $0x7,%eax
  8023e1:	e8 f2 fd ff ff       	call   8021d8 <fsipc>
}
  8023e6:	83 c4 14             	add    $0x14,%esp
  8023e9:	5b                   	pop    %ebx
  8023ea:	5d                   	pop    %ebp
  8023eb:	c3                   	ret    

008023ec <open>:
// 	The file descriptor index on success
// 	-E_BAD_PATH if the path is too long (>= MAXPATHLEN)
// 	< 0 for other errors.
int
open(const char *path, int mode)
{
  8023ec:	55                   	push   %ebp
  8023ed:	89 e5                	mov    %esp,%ebp
  8023ef:	83 ec 28             	sub    $0x28,%esp
  8023f2:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8023f5:	89 75 fc             	mov    %esi,-0x4(%ebp)
  8023f8:	8b 75 08             	mov    0x8(%ebp),%esi
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  int r   = 0;

  if (!path)
  8023fb:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  802400:	85 f6                	test   %esi,%esi
  802402:	74 65                	je     802469 <open+0x7d>
	// (fd_alloc does not allocate a page, it just returns an
	// unused fd address.  Do you need to allocate a page?)
	//
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  802404:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  int r   = 0;

  if (!path)
    return -E_INVAL;
  if((r=fd_alloc(&f))<0)
  80240b:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80240e:	89 04 24             	mov    %eax,(%esp)
  802411:	e8 75 f7 ff ff       	call   801b8b <fd_alloc>
  802416:	89 c3                	mov    %eax,%ebx
  802418:	85 c0                	test   %eax,%eax
  80241a:	78 4d                	js     802469 <open+0x7d>
    return r;

	strcpy(fsipcbuf.open.req_path, path);
  80241c:	89 74 24 04          	mov    %esi,0x4(%esp)
  802420:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  802427:	e8 de e9 ff ff       	call   800e0a <strcpy>
	fsipcbuf.open.req_omode = mode;
  80242c:	8b 45 0c             	mov    0xc(%ebp),%eax
  80242f:	a3 00 44 80 00       	mov    %eax,0x804400

  if ((r=fsipc(FSREQ_OPEN, f))<0) {
  802434:	8b 55 f4             	mov    -0xc(%ebp),%edx
  802437:	b8 01 00 00 00       	mov    $0x1,%eax
  80243c:	e8 97 fd ff ff       	call   8021d8 <fsipc>
  802441:	89 c3                	mov    %eax,%ebx
  802443:	85 c0                	test   %eax,%eax
  802445:	79 15                	jns    80245c <open+0x70>
    fd_close(f, 0);
  802447:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  80244e:	00 
  80244f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802452:	89 04 24             	mov    %eax,(%esp)
  802455:	e8 3a fb ff ff       	call   801f94 <fd_close>
    return r;
  80245a:	eb 0d                	jmp    802469 <open+0x7d>
  }
  return fd2num(f);
  80245c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80245f:	89 04 24             	mov    %eax,(%esp)
  802462:	e8 f9 f6 ff ff       	call   801b60 <fd2num>
  802467:	89 c3                	mov    %eax,%ebx
}
  802469:	89 d8                	mov    %ebx,%eax
  80246b:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80246e:	8b 75 fc             	mov    -0x4(%ebp),%esi
  802471:	89 ec                	mov    %ebp,%esp
  802473:	5d                   	pop    %ebp
  802474:	c3                   	ret    
	...

00802480 <devsock_stat>:
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
}

static int
devsock_stat(struct Fd *fd, struct Stat *stat)
{
  802480:	55                   	push   %ebp
  802481:	89 e5                	mov    %esp,%ebp
  802483:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<sock>");
  802486:	c7 44 24 04 f8 3c 80 	movl   $0x803cf8,0x4(%esp)
  80248d:	00 
  80248e:	8b 45 0c             	mov    0xc(%ebp),%eax
  802491:	89 04 24             	mov    %eax,(%esp)
  802494:	e8 71 e9 ff ff       	call   800e0a <strcpy>
	return 0;
}
  802499:	b8 00 00 00 00       	mov    $0x0,%eax
  80249e:	c9                   	leave  
  80249f:	c3                   	ret    

008024a0 <devsock_close>:
	return nsipc_shutdown(r, how);
}

static int
devsock_close(struct Fd *fd)
{
  8024a0:	55                   	push   %ebp
  8024a1:	89 e5                	mov    %esp,%ebp
  8024a3:	83 ec 18             	sub    $0x18,%esp
	return nsipc_close(fd->fd_sock.sockid);
  8024a6:	8b 45 08             	mov    0x8(%ebp),%eax
  8024a9:	8b 40 0c             	mov    0xc(%eax),%eax
  8024ac:	89 04 24             	mov    %eax,(%esp)
  8024af:	e8 9d 02 00 00       	call   802751 <nsipc_close>
}
  8024b4:	c9                   	leave  
  8024b5:	c3                   	ret    

008024b6 <devsock_write>:
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
}

static ssize_t
devsock_write(struct Fd *fd, const void *buf, size_t n)
{
  8024b6:	55                   	push   %ebp
  8024b7:	89 e5                	mov    %esp,%ebp
  8024b9:	83 ec 18             	sub    $0x18,%esp
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
  8024bc:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8024c3:	00 
  8024c4:	8b 45 10             	mov    0x10(%ebp),%eax
  8024c7:	89 44 24 08          	mov    %eax,0x8(%esp)
  8024cb:	8b 45 0c             	mov    0xc(%ebp),%eax
  8024ce:	89 44 24 04          	mov    %eax,0x4(%esp)
  8024d2:	8b 45 08             	mov    0x8(%ebp),%eax
  8024d5:	8b 40 0c             	mov    0xc(%eax),%eax
  8024d8:	89 04 24             	mov    %eax,(%esp)
  8024db:	e8 ad 02 00 00       	call   80278d <nsipc_send>
}
  8024e0:	c9                   	leave  
  8024e1:	c3                   	ret    

008024e2 <devsock_read>:
	return nsipc_listen(r, backlog);
}

static ssize_t
devsock_read(struct Fd *fd, void *buf, size_t n)
{
  8024e2:	55                   	push   %ebp
  8024e3:	89 e5                	mov    %esp,%ebp
  8024e5:	83 ec 18             	sub    $0x18,%esp
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
  8024e8:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8024ef:	00 
  8024f0:	8b 45 10             	mov    0x10(%ebp),%eax
  8024f3:	89 44 24 08          	mov    %eax,0x8(%esp)
  8024f7:	8b 45 0c             	mov    0xc(%ebp),%eax
  8024fa:	89 44 24 04          	mov    %eax,0x4(%esp)
  8024fe:	8b 45 08             	mov    0x8(%ebp),%eax
  802501:	8b 40 0c             	mov    0xc(%eax),%eax
  802504:	89 04 24             	mov    %eax,(%esp)
  802507:	e8 f4 02 00 00       	call   802800 <nsipc_recv>
}
  80250c:	c9                   	leave  
  80250d:	c3                   	ret    

0080250e <alloc_sockfd>:
	return sfd->fd_sock.sockid;
}

static int
alloc_sockfd(int sockid)
{
  80250e:	55                   	push   %ebp
  80250f:	89 e5                	mov    %esp,%ebp
  802511:	56                   	push   %esi
  802512:	53                   	push   %ebx
  802513:	83 ec 20             	sub    $0x20,%esp
  802516:	89 c6                	mov    %eax,%esi
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  802518:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80251b:	89 04 24             	mov    %eax,(%esp)
  80251e:	e8 68 f6 ff ff       	call   801b8b <fd_alloc>
  802523:	89 c3                	mov    %eax,%ebx
  802525:	85 c0                	test   %eax,%eax
  802527:	78 21                	js     80254a <alloc_sockfd+0x3c>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
  802529:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  802530:	00 
  802531:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802534:	89 44 24 04          	mov    %eax,0x4(%esp)
  802538:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80253f:	e8 22 f0 ff ff       	call   801566 <sys_page_alloc>
  802544:	89 c3                	mov    %eax,%ebx
alloc_sockfd(int sockid)
{
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  802546:	85 c0                	test   %eax,%eax
  802548:	79 0a                	jns    802554 <alloc_sockfd+0x46>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
		nsipc_close(sockid);
  80254a:	89 34 24             	mov    %esi,(%esp)
  80254d:	e8 ff 01 00 00       	call   802751 <nsipc_close>
		return r;
  802552:	eb 28                	jmp    80257c <alloc_sockfd+0x6e>
	}

	sfd->fd_dev_id = devsock.dev_id;
  802554:	8b 15 20 70 80 00    	mov    0x807020,%edx
  80255a:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80255d:	89 10                	mov    %edx,(%eax)
	sfd->fd_omode = O_RDWR;
  80255f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802562:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	sfd->fd_sock.sockid = sockid;
  802569:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80256c:	89 70 0c             	mov    %esi,0xc(%eax)
	return fd2num(sfd);
  80256f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802572:	89 04 24             	mov    %eax,(%esp)
  802575:	e8 e6 f5 ff ff       	call   801b60 <fd2num>
  80257a:	89 c3                	mov    %eax,%ebx
}
  80257c:	89 d8                	mov    %ebx,%eax
  80257e:	83 c4 20             	add    $0x20,%esp
  802581:	5b                   	pop    %ebx
  802582:	5e                   	pop    %esi
  802583:	5d                   	pop    %ebp
  802584:	c3                   	ret    

00802585 <socket>:
	return 0;
}

int
socket(int domain, int type, int protocol)
{
  802585:	55                   	push   %ebp
  802586:	89 e5                	mov    %esp,%ebp
  802588:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = nsipc_socket(domain, type, protocol)) < 0)
  80258b:	8b 45 10             	mov    0x10(%ebp),%eax
  80258e:	89 44 24 08          	mov    %eax,0x8(%esp)
  802592:	8b 45 0c             	mov    0xc(%ebp),%eax
  802595:	89 44 24 04          	mov    %eax,0x4(%esp)
  802599:	8b 45 08             	mov    0x8(%ebp),%eax
  80259c:	89 04 24             	mov    %eax,(%esp)
  80259f:	e8 61 01 00 00       	call   802705 <nsipc_socket>
  8025a4:	85 c0                	test   %eax,%eax
  8025a6:	78 05                	js     8025ad <socket+0x28>
		return r;
	return alloc_sockfd(r);
  8025a8:	e8 61 ff ff ff       	call   80250e <alloc_sockfd>
}
  8025ad:	c9                   	leave  
  8025ae:	66 90                	xchg   %ax,%ax
  8025b0:	c3                   	ret    

008025b1 <fd2sockid>:
	.dev_stat =	devsock_stat,
};

static int
fd2sockid(int fd)
{
  8025b1:	55                   	push   %ebp
  8025b2:	89 e5                	mov    %esp,%ebp
  8025b4:	83 ec 28             	sub    $0x28,%esp
	struct Fd *sfd;
	int r;

	if ((r = fd_lookup(fd, &sfd)) < 0)
  8025b7:	8d 55 f4             	lea    -0xc(%ebp),%edx
  8025ba:	89 54 24 04          	mov    %edx,0x4(%esp)
  8025be:	89 04 24             	mov    %eax,(%esp)
  8025c1:	e8 37 f6 ff ff       	call   801bfd <fd_lookup>
  8025c6:	85 c0                	test   %eax,%eax
  8025c8:	78 15                	js     8025df <fd2sockid+0x2e>
		return r;
	if (sfd->fd_dev_id != devsock.dev_id)
  8025ca:	8b 55 f4             	mov    -0xc(%ebp),%edx
  8025cd:	8b 0a                	mov    (%edx),%ecx
  8025cf:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8025d4:	3b 0d 20 70 80 00    	cmp    0x807020,%ecx
  8025da:	75 03                	jne    8025df <fd2sockid+0x2e>
		return -E_NOT_SUPP;
	return sfd->fd_sock.sockid;
  8025dc:	8b 42 0c             	mov    0xc(%edx),%eax
}
  8025df:	c9                   	leave  
  8025e0:	c3                   	ret    

008025e1 <listen>:
	return nsipc_connect(r, name, namelen);
}

int
listen(int s, int backlog)
{
  8025e1:	55                   	push   %ebp
  8025e2:	89 e5                	mov    %esp,%ebp
  8025e4:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  8025e7:	8b 45 08             	mov    0x8(%ebp),%eax
  8025ea:	e8 c2 ff ff ff       	call   8025b1 <fd2sockid>
  8025ef:	85 c0                	test   %eax,%eax
  8025f1:	78 0f                	js     802602 <listen+0x21>
		return r;
	return nsipc_listen(r, backlog);
  8025f3:	8b 55 0c             	mov    0xc(%ebp),%edx
  8025f6:	89 54 24 04          	mov    %edx,0x4(%esp)
  8025fa:	89 04 24             	mov    %eax,(%esp)
  8025fd:	e8 2d 01 00 00       	call   80272f <nsipc_listen>
}
  802602:	c9                   	leave  
  802603:	c3                   	ret    

00802604 <connect>:
	return nsipc_close(fd->fd_sock.sockid);
}

int
connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  802604:	55                   	push   %ebp
  802605:	89 e5                	mov    %esp,%ebp
  802607:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  80260a:	8b 45 08             	mov    0x8(%ebp),%eax
  80260d:	e8 9f ff ff ff       	call   8025b1 <fd2sockid>
  802612:	85 c0                	test   %eax,%eax
  802614:	78 16                	js     80262c <connect+0x28>
		return r;
	return nsipc_connect(r, name, namelen);
  802616:	8b 55 10             	mov    0x10(%ebp),%edx
  802619:	89 54 24 08          	mov    %edx,0x8(%esp)
  80261d:	8b 55 0c             	mov    0xc(%ebp),%edx
  802620:	89 54 24 04          	mov    %edx,0x4(%esp)
  802624:	89 04 24             	mov    %eax,(%esp)
  802627:	e8 54 02 00 00       	call   802880 <nsipc_connect>
}
  80262c:	c9                   	leave  
  80262d:	c3                   	ret    

0080262e <shutdown>:
	return nsipc_bind(r, name, namelen);
}

int
shutdown(int s, int how)
{
  80262e:	55                   	push   %ebp
  80262f:	89 e5                	mov    %esp,%ebp
  802631:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802634:	8b 45 08             	mov    0x8(%ebp),%eax
  802637:	e8 75 ff ff ff       	call   8025b1 <fd2sockid>
  80263c:	85 c0                	test   %eax,%eax
  80263e:	78 0f                	js     80264f <shutdown+0x21>
		return r;
	return nsipc_shutdown(r, how);
  802640:	8b 55 0c             	mov    0xc(%ebp),%edx
  802643:	89 54 24 04          	mov    %edx,0x4(%esp)
  802647:	89 04 24             	mov    %eax,(%esp)
  80264a:	e8 1c 01 00 00       	call   80276b <nsipc_shutdown>
}
  80264f:	c9                   	leave  
  802650:	c3                   	ret    

00802651 <bind>:
	return alloc_sockfd(r);
}

int
bind(int s, struct sockaddr *name, socklen_t namelen)
{
  802651:	55                   	push   %ebp
  802652:	89 e5                	mov    %esp,%ebp
  802654:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802657:	8b 45 08             	mov    0x8(%ebp),%eax
  80265a:	e8 52 ff ff ff       	call   8025b1 <fd2sockid>
  80265f:	85 c0                	test   %eax,%eax
  802661:	78 16                	js     802679 <bind+0x28>
		return r;
	return nsipc_bind(r, name, namelen);
  802663:	8b 55 10             	mov    0x10(%ebp),%edx
  802666:	89 54 24 08          	mov    %edx,0x8(%esp)
  80266a:	8b 55 0c             	mov    0xc(%ebp),%edx
  80266d:	89 54 24 04          	mov    %edx,0x4(%esp)
  802671:	89 04 24             	mov    %eax,(%esp)
  802674:	e8 46 02 00 00       	call   8028bf <nsipc_bind>
}
  802679:	c9                   	leave  
  80267a:	c3                   	ret    

0080267b <accept>:
	return fd2num(sfd);
}

int
accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  80267b:	55                   	push   %ebp
  80267c:	89 e5                	mov    %esp,%ebp
  80267e:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802681:	8b 45 08             	mov    0x8(%ebp),%eax
  802684:	e8 28 ff ff ff       	call   8025b1 <fd2sockid>
  802689:	85 c0                	test   %eax,%eax
  80268b:	78 1f                	js     8026ac <accept+0x31>
		return r;
	if ((r = nsipc_accept(r, addr, addrlen)) < 0)
  80268d:	8b 55 10             	mov    0x10(%ebp),%edx
  802690:	89 54 24 08          	mov    %edx,0x8(%esp)
  802694:	8b 55 0c             	mov    0xc(%ebp),%edx
  802697:	89 54 24 04          	mov    %edx,0x4(%esp)
  80269b:	89 04 24             	mov    %eax,(%esp)
  80269e:	e8 5b 02 00 00       	call   8028fe <nsipc_accept>
  8026a3:	85 c0                	test   %eax,%eax
  8026a5:	78 05                	js     8026ac <accept+0x31>
		return r;
	return alloc_sockfd(r);
  8026a7:	e8 62 fe ff ff       	call   80250e <alloc_sockfd>
}
  8026ac:	c9                   	leave  
  8026ad:	8d 76 00             	lea    0x0(%esi),%esi
  8026b0:	c3                   	ret    
	...

008026c0 <nsipc>:
// may be written back to nsipcbuf.
// type: request code, passed as the simple integer IPC value.
// Returns 0 if successful, < 0 on failure.
static int
nsipc(unsigned type)
{
  8026c0:	55                   	push   %ebp
  8026c1:	89 e5                	mov    %esp,%ebp
  8026c3:	83 ec 28             	sub    $0x28,%esp
    int r=0;
    envid_t from;
	if (debug)
		cprintf("[%08x] nsipc %d\n", env->env_id, type);

	ipc_send(envs[2].env_id, type, &nsipcbuf, PTE_P|PTE_W|PTE_U);
  8026c6:	8b 15 44 01 c0 ee    	mov    0xeec00144,%edx
  8026cc:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  8026d3:	00 
  8026d4:	c7 44 24 08 00 60 80 	movl   $0x806000,0x8(%esp)
  8026db:	00 
  8026dc:	89 44 24 04          	mov    %eax,0x4(%esp)
  8026e0:	89 14 24             	mov    %edx,(%esp)
  8026e3:	e8 a8 f3 ff ff       	call   801a90 <ipc_send>
	r=ipc_recv(&from, NULL, NULL);
  8026e8:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8026ef:	00 
  8026f0:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  8026f7:	00 
  8026f8:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8026fb:	89 04 24             	mov    %eax,(%esp)
  8026fe:	e8 ff f3 ff ff       	call   801b02 <ipc_recv>
    return r;
}
  802703:	c9                   	leave  
  802704:	c3                   	ret    

00802705 <nsipc_socket>:
	return nsipc(NSREQ_SEND);
}

int
nsipc_socket(int domain, int type, int protocol)
{
  802705:	55                   	push   %ebp
  802706:	89 e5                	mov    %esp,%ebp
  802708:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.socket.req_domain = domain;
  80270b:	8b 45 08             	mov    0x8(%ebp),%eax
  80270e:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.socket.req_type = type;
  802713:	8b 45 0c             	mov    0xc(%ebp),%eax
  802716:	a3 04 60 80 00       	mov    %eax,0x806004
	nsipcbuf.socket.req_protocol = protocol;
  80271b:	8b 45 10             	mov    0x10(%ebp),%eax
  80271e:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SOCKET);
  802723:	b8 09 00 00 00       	mov    $0x9,%eax
  802728:	e8 93 ff ff ff       	call   8026c0 <nsipc>
}
  80272d:	c9                   	leave  
  80272e:	c3                   	ret    

0080272f <nsipc_listen>:
	return nsipc(NSREQ_CONNECT);
}

int
nsipc_listen(int s, int backlog)
{
  80272f:	55                   	push   %ebp
  802730:	89 e5                	mov    %esp,%ebp
  802732:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.listen.req_s = s;
  802735:	8b 45 08             	mov    0x8(%ebp),%eax
  802738:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.listen.req_backlog = backlog;
  80273d:	8b 45 0c             	mov    0xc(%ebp),%eax
  802740:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_LISTEN);
  802745:	b8 06 00 00 00       	mov    $0x6,%eax
  80274a:	e8 71 ff ff ff       	call   8026c0 <nsipc>
}
  80274f:	c9                   	leave  
  802750:	c3                   	ret    

00802751 <nsipc_close>:
	return nsipc(NSREQ_SHUTDOWN);
}

int
nsipc_close(int s)
{
  802751:	55                   	push   %ebp
  802752:	89 e5                	mov    %esp,%ebp
  802754:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.close.req_s = s;
  802757:	8b 45 08             	mov    0x8(%ebp),%eax
  80275a:	a3 00 60 80 00       	mov    %eax,0x806000
	return nsipc(NSREQ_CLOSE);
  80275f:	b8 04 00 00 00       	mov    $0x4,%eax
  802764:	e8 57 ff ff ff       	call   8026c0 <nsipc>
}
  802769:	c9                   	leave  
  80276a:	c3                   	ret    

0080276b <nsipc_shutdown>:
	return nsipc(NSREQ_BIND);
}

int
nsipc_shutdown(int s, int how)
{
  80276b:	55                   	push   %ebp
  80276c:	89 e5                	mov    %esp,%ebp
  80276e:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.shutdown.req_s = s;
  802771:	8b 45 08             	mov    0x8(%ebp),%eax
  802774:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.shutdown.req_how = how;
  802779:	8b 45 0c             	mov    0xc(%ebp),%eax
  80277c:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_SHUTDOWN);
  802781:	b8 03 00 00 00       	mov    $0x3,%eax
  802786:	e8 35 ff ff ff       	call   8026c0 <nsipc>
}
  80278b:	c9                   	leave  
  80278c:	c3                   	ret    

0080278d <nsipc_send>:
	return r;
}

int
nsipc_send(int s, const void *buf, int size, unsigned int flags)
{
  80278d:	55                   	push   %ebp
  80278e:	89 e5                	mov    %esp,%ebp
  802790:	53                   	push   %ebx
  802791:	83 ec 14             	sub    $0x14,%esp
  802794:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.send.req_s = s;
  802797:	8b 45 08             	mov    0x8(%ebp),%eax
  80279a:	a3 00 60 80 00       	mov    %eax,0x806000
	assert(size < 1600);
  80279f:	81 fb 3f 06 00 00    	cmp    $0x63f,%ebx
  8027a5:	7e 24                	jle    8027cb <nsipc_send+0x3e>
  8027a7:	c7 44 24 0c 04 3d 80 	movl   $0x803d04,0xc(%esp)
  8027ae:	00 
  8027af:	c7 44 24 08 10 3d 80 	movl   $0x803d10,0x8(%esp)
  8027b6:	00 
  8027b7:	c7 44 24 04 69 00 00 	movl   $0x69,0x4(%esp)
  8027be:	00 
  8027bf:	c7 04 24 25 3d 80 00 	movl   $0x803d25,(%esp)
  8027c6:	e8 b1 de ff ff       	call   80067c <_panic>
	memmove(&nsipcbuf.send.req_buf, buf, size);
  8027cb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8027cf:	8b 45 0c             	mov    0xc(%ebp),%eax
  8027d2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8027d6:	c7 04 24 0c 60 80 00 	movl   $0x80600c,(%esp)
  8027dd:	e8 e3 e7 ff ff       	call   800fc5 <memmove>
	nsipcbuf.send.req_size = size;
  8027e2:	89 1d 04 60 80 00    	mov    %ebx,0x806004
	nsipcbuf.send.req_flags = flags;
  8027e8:	8b 45 14             	mov    0x14(%ebp),%eax
  8027eb:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SEND);
  8027f0:	b8 08 00 00 00       	mov    $0x8,%eax
  8027f5:	e8 c6 fe ff ff       	call   8026c0 <nsipc>
}
  8027fa:	83 c4 14             	add    $0x14,%esp
  8027fd:	5b                   	pop    %ebx
  8027fe:	5d                   	pop    %ebp
  8027ff:	c3                   	ret    

00802800 <nsipc_recv>:
	return nsipc(NSREQ_LISTEN);
}

int
nsipc_recv(int s, void *mem, int len, unsigned int flags)
{
  802800:	55                   	push   %ebp
  802801:	89 e5                	mov    %esp,%ebp
  802803:	56                   	push   %esi
  802804:	53                   	push   %ebx
  802805:	83 ec 10             	sub    $0x10,%esp
  802808:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;

	nsipcbuf.recv.req_s = s;
  80280b:	8b 45 08             	mov    0x8(%ebp),%eax
  80280e:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.recv.req_len = len;
  802813:	89 35 04 60 80 00    	mov    %esi,0x806004
	nsipcbuf.recv.req_flags = flags;
  802819:	8b 45 14             	mov    0x14(%ebp),%eax
  80281c:	a3 08 60 80 00       	mov    %eax,0x806008

	if ((r = nsipc(NSREQ_RECV)) >= 0) {
  802821:	b8 07 00 00 00       	mov    $0x7,%eax
  802826:	e8 95 fe ff ff       	call   8026c0 <nsipc>
  80282b:	89 c3                	mov    %eax,%ebx
  80282d:	85 c0                	test   %eax,%eax
  80282f:	78 46                	js     802877 <nsipc_recv+0x77>
		assert(r < 1600 && r <= len);
  802831:	3d 3f 06 00 00       	cmp    $0x63f,%eax
  802836:	7f 04                	jg     80283c <nsipc_recv+0x3c>
  802838:	39 c6                	cmp    %eax,%esi
  80283a:	7d 24                	jge    802860 <nsipc_recv+0x60>
  80283c:	c7 44 24 0c 31 3d 80 	movl   $0x803d31,0xc(%esp)
  802843:	00 
  802844:	c7 44 24 08 10 3d 80 	movl   $0x803d10,0x8(%esp)
  80284b:	00 
  80284c:	c7 44 24 04 5e 00 00 	movl   $0x5e,0x4(%esp)
  802853:	00 
  802854:	c7 04 24 25 3d 80 00 	movl   $0x803d25,(%esp)
  80285b:	e8 1c de ff ff       	call   80067c <_panic>
		memmove(mem, nsipcbuf.recvRet.ret_buf, r);
  802860:	89 44 24 08          	mov    %eax,0x8(%esp)
  802864:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  80286b:	00 
  80286c:	8b 45 0c             	mov    0xc(%ebp),%eax
  80286f:	89 04 24             	mov    %eax,(%esp)
  802872:	e8 4e e7 ff ff       	call   800fc5 <memmove>
	}

	return r;
}
  802877:	89 d8                	mov    %ebx,%eax
  802879:	83 c4 10             	add    $0x10,%esp
  80287c:	5b                   	pop    %ebx
  80287d:	5e                   	pop    %esi
  80287e:	5d                   	pop    %ebp
  80287f:	c3                   	ret    

00802880 <nsipc_connect>:
	return nsipc(NSREQ_CLOSE);
}

int
nsipc_connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  802880:	55                   	push   %ebp
  802881:	89 e5                	mov    %esp,%ebp
  802883:	53                   	push   %ebx
  802884:	83 ec 14             	sub    $0x14,%esp
  802887:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.connect.req_s = s;
  80288a:	8b 45 08             	mov    0x8(%ebp),%eax
  80288d:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.connect.req_name, name, namelen);
  802892:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802896:	8b 45 0c             	mov    0xc(%ebp),%eax
  802899:	89 44 24 04          	mov    %eax,0x4(%esp)
  80289d:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  8028a4:	e8 1c e7 ff ff       	call   800fc5 <memmove>
	nsipcbuf.connect.req_namelen = namelen;
  8028a9:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_CONNECT);
  8028af:	b8 05 00 00 00       	mov    $0x5,%eax
  8028b4:	e8 07 fe ff ff       	call   8026c0 <nsipc>
}
  8028b9:	83 c4 14             	add    $0x14,%esp
  8028bc:	5b                   	pop    %ebx
  8028bd:	5d                   	pop    %ebp
  8028be:	c3                   	ret    

008028bf <nsipc_bind>:
	return r;
}

int
nsipc_bind(int s, struct sockaddr *name, socklen_t namelen)
{
  8028bf:	55                   	push   %ebp
  8028c0:	89 e5                	mov    %esp,%ebp
  8028c2:	53                   	push   %ebx
  8028c3:	83 ec 14             	sub    $0x14,%esp
  8028c6:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.bind.req_s = s;
  8028c9:	8b 45 08             	mov    0x8(%ebp),%eax
  8028cc:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.bind.req_name, name, namelen);
  8028d1:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8028d5:	8b 45 0c             	mov    0xc(%ebp),%eax
  8028d8:	89 44 24 04          	mov    %eax,0x4(%esp)
  8028dc:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  8028e3:	e8 dd e6 ff ff       	call   800fc5 <memmove>
	nsipcbuf.bind.req_namelen = namelen;
  8028e8:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_BIND);
  8028ee:	b8 02 00 00 00       	mov    $0x2,%eax
  8028f3:	e8 c8 fd ff ff       	call   8026c0 <nsipc>
}
  8028f8:	83 c4 14             	add    $0x14,%esp
  8028fb:	5b                   	pop    %ebx
  8028fc:	5d                   	pop    %ebp
  8028fd:	c3                   	ret    

008028fe <nsipc_accept>:
    return r;
}

int
nsipc_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  8028fe:	55                   	push   %ebp
  8028ff:	89 e5                	mov    %esp,%ebp
  802901:	83 ec 18             	sub    $0x18,%esp
  802904:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802907:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int r;
	
	nsipcbuf.accept.req_s = s;
  80290a:	8b 45 08             	mov    0x8(%ebp),%eax
  80290d:	a3 00 60 80 00       	mov    %eax,0x806000
	if ((r = nsipc(NSREQ_ACCEPT)) >= 0) {
  802912:	b8 01 00 00 00       	mov    $0x1,%eax
  802917:	e8 a4 fd ff ff       	call   8026c0 <nsipc>
  80291c:	89 c3                	mov    %eax,%ebx
  80291e:	85 c0                	test   %eax,%eax
  802920:	78 25                	js     802947 <nsipc_accept+0x49>
		struct Nsret_accept *ret = &nsipcbuf.acceptRet;
		memmove(addr, &ret->ret_addr, ret->ret_addrlen);
  802922:	be 10 60 80 00       	mov    $0x806010,%esi
  802927:	8b 06                	mov    (%esi),%eax
  802929:	89 44 24 08          	mov    %eax,0x8(%esp)
  80292d:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  802934:	00 
  802935:	8b 45 0c             	mov    0xc(%ebp),%eax
  802938:	89 04 24             	mov    %eax,(%esp)
  80293b:	e8 85 e6 ff ff       	call   800fc5 <memmove>
		*addrlen = ret->ret_addrlen;
  802940:	8b 16                	mov    (%esi),%edx
  802942:	8b 45 10             	mov    0x10(%ebp),%eax
  802945:	89 10                	mov    %edx,(%eax)
	}
	return r;
}
  802947:	89 d8                	mov    %ebx,%eax
  802949:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80294c:	8b 75 fc             	mov    -0x4(%ebp),%esi
  80294f:	89 ec                	mov    %ebp,%esp
  802951:	5d                   	pop    %ebp
  802952:	c3                   	ret    
	...

00802960 <devpipe_stat>:
	return i;
}

static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
  802960:	55                   	push   %ebp
  802961:	89 e5                	mov    %esp,%ebp
  802963:	83 ec 18             	sub    $0x18,%esp
  802966:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802969:	89 75 fc             	mov    %esi,-0x4(%ebp)
  80296c:	8b 75 0c             	mov    0xc(%ebp),%esi
	struct Pipe *p = (struct Pipe*) fd2data(fd);
  80296f:	8b 45 08             	mov    0x8(%ebp),%eax
  802972:	89 04 24             	mov    %eax,(%esp)
  802975:	e8 f6 f1 ff ff       	call   801b70 <fd2data>
  80297a:	89 c3                	mov    %eax,%ebx
	strcpy(stat->st_name, "<pipe>");
  80297c:	c7 44 24 04 46 3d 80 	movl   $0x803d46,0x4(%esp)
  802983:	00 
  802984:	89 34 24             	mov    %esi,(%esp)
  802987:	e8 7e e4 ff ff       	call   800e0a <strcpy>
	stat->st_size = p->p_wpos - p->p_rpos;
  80298c:	8b 43 04             	mov    0x4(%ebx),%eax
  80298f:	2b 03                	sub    (%ebx),%eax
  802991:	89 86 80 00 00 00    	mov    %eax,0x80(%esi)
	stat->st_isdir = 0;
  802997:	c7 86 84 00 00 00 00 	movl   $0x0,0x84(%esi)
  80299e:	00 00 00 
	stat->st_dev = &devpipe;
  8029a1:	c7 86 88 00 00 00 3c 	movl   $0x80703c,0x88(%esi)
  8029a8:	70 80 00 
	return 0;
}
  8029ab:	b8 00 00 00 00       	mov    $0x0,%eax
  8029b0:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8029b3:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8029b6:	89 ec                	mov    %ebp,%esp
  8029b8:	5d                   	pop    %ebp
  8029b9:	c3                   	ret    

008029ba <devpipe_close>:

static int
devpipe_close(struct Fd *fd)
{
  8029ba:	55                   	push   %ebp
  8029bb:	89 e5                	mov    %esp,%ebp
  8029bd:	53                   	push   %ebx
  8029be:	83 ec 14             	sub    $0x14,%esp
  8029c1:	8b 5d 08             	mov    0x8(%ebp),%ebx
	(void) sys_page_unmap(0, fd);
  8029c4:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8029c8:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8029cf:	e8 d6 ea ff ff       	call   8014aa <sys_page_unmap>
	return sys_page_unmap(0, fd2data(fd));
  8029d4:	89 1c 24             	mov    %ebx,(%esp)
  8029d7:	e8 94 f1 ff ff       	call   801b70 <fd2data>
  8029dc:	89 44 24 04          	mov    %eax,0x4(%esp)
  8029e0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8029e7:	e8 be ea ff ff       	call   8014aa <sys_page_unmap>
}
  8029ec:	83 c4 14             	add    $0x14,%esp
  8029ef:	5b                   	pop    %ebx
  8029f0:	5d                   	pop    %ebp
  8029f1:	c3                   	ret    

008029f2 <_pipeisclosed>:
	return r;
}

static int
_pipeisclosed(struct Fd *fd, struct Pipe *p)
{
  8029f2:	55                   	push   %ebp
  8029f3:	89 e5                	mov    %esp,%ebp
  8029f5:	57                   	push   %edi
  8029f6:	56                   	push   %esi
  8029f7:	53                   	push   %ebx
  8029f8:	83 ec 2c             	sub    $0x2c,%esp
  8029fb:	89 c7                	mov    %eax,%edi
  8029fd:	89 55 e4             	mov    %edx,-0x1c(%ebp)
	int n, nn, ret;

	while (1) {
		n = env->env_runs;
  802a00:	a1 8c 70 80 00       	mov    0x80708c,%eax
  802a05:	8b 58 58             	mov    0x58(%eax),%ebx
		ret = pageref(fd) == pageref(p);
  802a08:	89 3c 24             	mov    %edi,(%esp)
  802a0b:	e8 7c 05 00 00       	call   802f8c <pageref>
  802a10:	89 c6                	mov    %eax,%esi
  802a12:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802a15:	89 04 24             	mov    %eax,(%esp)
  802a18:	e8 6f 05 00 00       	call   802f8c <pageref>
  802a1d:	39 c6                	cmp    %eax,%esi
  802a1f:	0f 94 c0             	sete   %al
  802a22:	0f b6 c0             	movzbl %al,%eax
		nn = env->env_runs;
  802a25:	8b 15 8c 70 80 00    	mov    0x80708c,%edx
  802a2b:	8b 4a 58             	mov    0x58(%edx),%ecx
		if (n == nn)
  802a2e:	39 cb                	cmp    %ecx,%ebx
  802a30:	75 08                	jne    802a3a <_pipeisclosed+0x48>
			return ret;
		if (n != nn && ret == 1)
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
	}
}
  802a32:	83 c4 2c             	add    $0x2c,%esp
  802a35:	5b                   	pop    %ebx
  802a36:	5e                   	pop    %esi
  802a37:	5f                   	pop    %edi
  802a38:	5d                   	pop    %ebp
  802a39:	c3                   	ret    
		n = env->env_runs;
		ret = pageref(fd) == pageref(p);
		nn = env->env_runs;
		if (n == nn)
			return ret;
		if (n != nn && ret == 1)
  802a3a:	83 f8 01             	cmp    $0x1,%eax
  802a3d:	75 c1                	jne    802a00 <_pipeisclosed+0xe>
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
  802a3f:	8b 52 58             	mov    0x58(%edx),%edx
  802a42:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802a46:	89 54 24 08          	mov    %edx,0x8(%esp)
  802a4a:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802a4e:	c7 04 24 4d 3d 80 00 	movl   $0x803d4d,(%esp)
  802a55:	e8 e7 dc ff ff       	call   800741 <cprintf>
  802a5a:	eb a4                	jmp    802a00 <_pipeisclosed+0xe>

00802a5c <devpipe_write>:
	return i;
}

static ssize_t
devpipe_write(struct Fd *fd, const void *vbuf, size_t n)
{
  802a5c:	55                   	push   %ebp
  802a5d:	89 e5                	mov    %esp,%ebp
  802a5f:	57                   	push   %edi
  802a60:	56                   	push   %esi
  802a61:	53                   	push   %ebx
  802a62:	83 ec 1c             	sub    $0x1c,%esp
  802a65:	8b 75 08             	mov    0x8(%ebp),%esi
	const uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*) fd2data(fd);
  802a68:	89 34 24             	mov    %esi,(%esp)
  802a6b:	e8 00 f1 ff ff       	call   801b70 <fd2data>
  802a70:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802a72:	bf 00 00 00 00       	mov    $0x0,%edi
  802a77:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802a7b:	75 54                	jne    802ad1 <devpipe_write+0x75>
  802a7d:	eb 60                	jmp    802adf <devpipe_write+0x83>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
			// pipe is full
			// if all the readers are gone
			// (it's only writers like us now),
			// note eof
			if (_pipeisclosed(fd, p))
  802a7f:	89 da                	mov    %ebx,%edx
  802a81:	89 f0                	mov    %esi,%eax
  802a83:	e8 6a ff ff ff       	call   8029f2 <_pipeisclosed>
  802a88:	85 c0                	test   %eax,%eax
  802a8a:	74 07                	je     802a93 <devpipe_write+0x37>
  802a8c:	b8 00 00 00 00       	mov    $0x0,%eax
  802a91:	eb 53                	jmp    802ae6 <devpipe_write+0x8a>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_write yield\n");
			sys_yield();
  802a93:	90                   	nop
  802a94:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802a98:	e8 28 eb ff ff       	call   8015c5 <sys_yield>
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  802a9d:	8b 43 04             	mov    0x4(%ebx),%eax
  802aa0:	8b 13                	mov    (%ebx),%edx
  802aa2:	83 c2 20             	add    $0x20,%edx
  802aa5:	39 d0                	cmp    %edx,%eax
  802aa7:	73 d6                	jae    802a7f <devpipe_write+0x23>
				cprintf("devpipe_write yield\n");
			sys_yield();
		}
		// there's room for a byte.  store it.
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
  802aa9:	89 c2                	mov    %eax,%edx
  802aab:	c1 fa 1f             	sar    $0x1f,%edx
  802aae:	c1 ea 1b             	shr    $0x1b,%edx
  802ab1:	01 d0                	add    %edx,%eax
  802ab3:	83 e0 1f             	and    $0x1f,%eax
  802ab6:	29 d0                	sub    %edx,%eax
  802ab8:	89 c2                	mov    %eax,%edx
  802aba:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  802abd:	0f b6 04 39          	movzbl (%ecx,%edi,1),%eax
  802ac1:	88 44 13 08          	mov    %al,0x8(%ebx,%edx,1)
		p->p_wpos++;
  802ac5:	83 43 04 01          	addl   $0x1,0x4(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802ac9:	83 c7 01             	add    $0x1,%edi
  802acc:	39 7d 10             	cmp    %edi,0x10(%ebp)
  802acf:	76 13                	jbe    802ae4 <devpipe_write+0x88>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  802ad1:	8b 43 04             	mov    0x4(%ebx),%eax
  802ad4:	8b 13                	mov    (%ebx),%edx
  802ad6:	83 c2 20             	add    $0x20,%edx
  802ad9:	39 d0                	cmp    %edx,%eax
  802adb:	73 a2                	jae    802a7f <devpipe_write+0x23>
  802add:	eb ca                	jmp    802aa9 <devpipe_write+0x4d>
  802adf:	bf 00 00 00 00       	mov    $0x0,%edi
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
		p->p_wpos++;
	}
	
	return i;
  802ae4:	89 f8                	mov    %edi,%eax
}
  802ae6:	83 c4 1c             	add    $0x1c,%esp
  802ae9:	5b                   	pop    %ebx
  802aea:	5e                   	pop    %esi
  802aeb:	5f                   	pop    %edi
  802aec:	5d                   	pop    %ebp
  802aed:	c3                   	ret    

00802aee <devpipe_read>:
	return _pipeisclosed(fd, p);
}

static ssize_t
devpipe_read(struct Fd *fd, void *vbuf, size_t n)
{
  802aee:	55                   	push   %ebp
  802aef:	89 e5                	mov    %esp,%ebp
  802af1:	83 ec 28             	sub    $0x28,%esp
  802af4:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802af7:	89 75 f8             	mov    %esi,-0x8(%ebp)
  802afa:	89 7d fc             	mov    %edi,-0x4(%ebp)
  802afd:	8b 7d 08             	mov    0x8(%ebp),%edi
	uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*)fd2data(fd);
  802b00:	89 3c 24             	mov    %edi,(%esp)
  802b03:	e8 68 f0 ff ff       	call   801b70 <fd2data>
  802b08:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802b0a:	be 00 00 00 00       	mov    $0x0,%esi
  802b0f:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802b13:	75 4c                	jne    802b61 <devpipe_read+0x73>
  802b15:	eb 5b                	jmp    802b72 <devpipe_read+0x84>
		while (p->p_rpos == p->p_wpos) {
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
				return i;
  802b17:	89 f0                	mov    %esi,%eax
  802b19:	eb 5e                	jmp    802b79 <devpipe_read+0x8b>
			// if all the writers are gone, note eof
			if (_pipeisclosed(fd, p))
  802b1b:	89 da                	mov    %ebx,%edx
  802b1d:	89 f8                	mov    %edi,%eax
  802b1f:	90                   	nop
  802b20:	e8 cd fe ff ff       	call   8029f2 <_pipeisclosed>
  802b25:	85 c0                	test   %eax,%eax
  802b27:	74 07                	je     802b30 <devpipe_read+0x42>
  802b29:	b8 00 00 00 00       	mov    $0x0,%eax
  802b2e:	eb 49                	jmp    802b79 <devpipe_read+0x8b>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_read yield\n");
			sys_yield();
  802b30:	e8 90 ea ff ff       	call   8015c5 <sys_yield>
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_rpos == p->p_wpos) {
  802b35:	8b 03                	mov    (%ebx),%eax
  802b37:	3b 43 04             	cmp    0x4(%ebx),%eax
  802b3a:	74 df                	je     802b1b <devpipe_read+0x2d>
				cprintf("devpipe_read yield\n");
			sys_yield();
		}
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
  802b3c:	89 c2                	mov    %eax,%edx
  802b3e:	c1 fa 1f             	sar    $0x1f,%edx
  802b41:	c1 ea 1b             	shr    $0x1b,%edx
  802b44:	01 d0                	add    %edx,%eax
  802b46:	83 e0 1f             	and    $0x1f,%eax
  802b49:	29 d0                	sub    %edx,%eax
  802b4b:	0f b6 44 03 08       	movzbl 0x8(%ebx,%eax,1),%eax
  802b50:	8b 55 0c             	mov    0xc(%ebp),%edx
  802b53:	88 04 32             	mov    %al,(%edx,%esi,1)
		p->p_rpos++;
  802b56:	83 03 01             	addl   $0x1,(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802b59:	83 c6 01             	add    $0x1,%esi
  802b5c:	39 75 10             	cmp    %esi,0x10(%ebp)
  802b5f:	76 16                	jbe    802b77 <devpipe_read+0x89>
		while (p->p_rpos == p->p_wpos) {
  802b61:	8b 03                	mov    (%ebx),%eax
  802b63:	3b 43 04             	cmp    0x4(%ebx),%eax
  802b66:	75 d4                	jne    802b3c <devpipe_read+0x4e>
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
  802b68:	85 f6                	test   %esi,%esi
  802b6a:	75 ab                	jne    802b17 <devpipe_read+0x29>
  802b6c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802b70:	eb a9                	jmp    802b1b <devpipe_read+0x2d>
  802b72:	be 00 00 00 00       	mov    $0x0,%esi
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
		p->p_rpos++;
	}
	return i;
  802b77:	89 f0                	mov    %esi,%eax
}
  802b79:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  802b7c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  802b7f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802b82:	89 ec                	mov    %ebp,%esp
  802b84:	5d                   	pop    %ebp
  802b85:	c3                   	ret    

00802b86 <pipeisclosed>:
	}
}

int
pipeisclosed(int fdnum)
{
  802b86:	55                   	push   %ebp
  802b87:	89 e5                	mov    %esp,%ebp
  802b89:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	struct Pipe *p;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  802b8c:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802b8f:	89 44 24 04          	mov    %eax,0x4(%esp)
  802b93:	8b 45 08             	mov    0x8(%ebp),%eax
  802b96:	89 04 24             	mov    %eax,(%esp)
  802b99:	e8 5f f0 ff ff       	call   801bfd <fd_lookup>
  802b9e:	85 c0                	test   %eax,%eax
  802ba0:	78 15                	js     802bb7 <pipeisclosed+0x31>
		return r;
	p = (struct Pipe*) fd2data(fd);
  802ba2:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802ba5:	89 04 24             	mov    %eax,(%esp)
  802ba8:	e8 c3 ef ff ff       	call   801b70 <fd2data>
	return _pipeisclosed(fd, p);
  802bad:	89 c2                	mov    %eax,%edx
  802baf:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802bb2:	e8 3b fe ff ff       	call   8029f2 <_pipeisclosed>
}
  802bb7:	c9                   	leave  
  802bb8:	c3                   	ret    

00802bb9 <pipe>:
	uint8_t p_buf[PIPEBUFSIZ];	// data buffer
};

int
pipe(int pfd[2])
{
  802bb9:	55                   	push   %ebp
  802bba:	89 e5                	mov    %esp,%ebp
  802bbc:	83 ec 48             	sub    $0x48,%esp
  802bbf:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802bc2:	89 75 f8             	mov    %esi,-0x8(%ebp)
  802bc5:	89 7d fc             	mov    %edi,-0x4(%ebp)
  802bc8:	8b 7d 08             	mov    0x8(%ebp),%edi
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  802bcb:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  802bce:	89 04 24             	mov    %eax,(%esp)
  802bd1:	e8 b5 ef ff ff       	call   801b8b <fd_alloc>
  802bd6:	89 c3                	mov    %eax,%ebx
  802bd8:	85 c0                	test   %eax,%eax
  802bda:	0f 88 42 01 00 00    	js     802d22 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802be0:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802be7:	00 
  802be8:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802beb:	89 44 24 04          	mov    %eax,0x4(%esp)
  802bef:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802bf6:	e8 6b e9 ff ff       	call   801566 <sys_page_alloc>
  802bfb:	89 c3                	mov    %eax,%ebx
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  802bfd:	85 c0                	test   %eax,%eax
  802bff:	0f 88 1d 01 00 00    	js     802d22 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  802c05:	8d 45 e0             	lea    -0x20(%ebp),%eax
  802c08:	89 04 24             	mov    %eax,(%esp)
  802c0b:	e8 7b ef ff ff       	call   801b8b <fd_alloc>
  802c10:	89 c3                	mov    %eax,%ebx
  802c12:	85 c0                	test   %eax,%eax
  802c14:	0f 88 f5 00 00 00    	js     802d0f <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802c1a:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802c21:	00 
  802c22:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802c25:	89 44 24 04          	mov    %eax,0x4(%esp)
  802c29:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802c30:	e8 31 e9 ff ff       	call   801566 <sys_page_alloc>
  802c35:	89 c3                	mov    %eax,%ebx
	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  802c37:	85 c0                	test   %eax,%eax
  802c39:	0f 88 d0 00 00 00    	js     802d0f <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err1;

	// allocate the pipe structure as first data page in both
	va = fd2data(fd0);
  802c3f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802c42:	89 04 24             	mov    %eax,(%esp)
  802c45:	e8 26 ef ff ff       	call   801b70 <fd2data>
  802c4a:	89 c6                	mov    %eax,%esi
	if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802c4c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802c53:	00 
  802c54:	89 44 24 04          	mov    %eax,0x4(%esp)
  802c58:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802c5f:	e8 02 e9 ff ff       	call   801566 <sys_page_alloc>
  802c64:	89 c3                	mov    %eax,%ebx
  802c66:	85 c0                	test   %eax,%eax
  802c68:	0f 88 8e 00 00 00    	js     802cfc <pipe+0x143>
		goto err2;
	if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802c6e:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802c71:	89 04 24             	mov    %eax,(%esp)
  802c74:	e8 f7 ee ff ff       	call   801b70 <fd2data>
  802c79:	c7 44 24 10 07 04 00 	movl   $0x407,0x10(%esp)
  802c80:	00 
  802c81:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802c85:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  802c8c:	00 
  802c8d:	89 74 24 04          	mov    %esi,0x4(%esp)
  802c91:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802c98:	e8 6b e8 ff ff       	call   801508 <sys_page_map>
  802c9d:	89 c3                	mov    %eax,%ebx
  802c9f:	85 c0                	test   %eax,%eax
  802ca1:	78 49                	js     802cec <pipe+0x133>
		goto err3;

	// set up fd structures
	fd0->fd_dev_id = devpipe.dev_id;
  802ca3:	b8 3c 70 80 00       	mov    $0x80703c,%eax
  802ca8:	8b 08                	mov    (%eax),%ecx
  802caa:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  802cad:	89 0a                	mov    %ecx,(%edx)
	fd0->fd_omode = O_RDONLY;
  802caf:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  802cb2:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)

	fd1->fd_dev_id = devpipe.dev_id;
  802cb9:	8b 10                	mov    (%eax),%edx
  802cbb:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802cbe:	89 10                	mov    %edx,(%eax)
	fd1->fd_omode = O_WRONLY;
  802cc0:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802cc3:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%eax)

	if (debug)
		cprintf("[%08x] pipecreate %08x\n", env->env_id, vpt[VPN(va)]);

	pfd[0] = fd2num(fd0);
  802cca:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802ccd:	89 04 24             	mov    %eax,(%esp)
  802cd0:	e8 8b ee ff ff       	call   801b60 <fd2num>
  802cd5:	89 07                	mov    %eax,(%edi)
	pfd[1] = fd2num(fd1);
  802cd7:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802cda:	89 04 24             	mov    %eax,(%esp)
  802cdd:	e8 7e ee ff ff       	call   801b60 <fd2num>
  802ce2:	89 47 04             	mov    %eax,0x4(%edi)
  802ce5:	bb 00 00 00 00       	mov    $0x0,%ebx
	return 0;
  802cea:	eb 36                	jmp    802d22 <pipe+0x169>

    err3:
	sys_page_unmap(0, va);
  802cec:	89 74 24 04          	mov    %esi,0x4(%esp)
  802cf0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802cf7:	e8 ae e7 ff ff       	call   8014aa <sys_page_unmap>
    err2:
	sys_page_unmap(0, fd1);
  802cfc:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802cff:	89 44 24 04          	mov    %eax,0x4(%esp)
  802d03:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802d0a:	e8 9b e7 ff ff       	call   8014aa <sys_page_unmap>
    err1:
	sys_page_unmap(0, fd0);
  802d0f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802d12:	89 44 24 04          	mov    %eax,0x4(%esp)
  802d16:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802d1d:	e8 88 e7 ff ff       	call   8014aa <sys_page_unmap>
    err:
	return r;
}
  802d22:	89 d8                	mov    %ebx,%eax
  802d24:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  802d27:	8b 75 f8             	mov    -0x8(%ebp),%esi
  802d2a:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802d2d:	89 ec                	mov    %ebp,%esp
  802d2f:	5d                   	pop    %ebp
  802d30:	c3                   	ret    
	...

00802d40 <devcons_close>:
	return tot;
}

static int
devcons_close(struct Fd *fd)
{
  802d40:	55                   	push   %ebp
  802d41:	89 e5                	mov    %esp,%ebp
	USED(fd);

	return 0;
}
  802d43:	b8 00 00 00 00       	mov    $0x0,%eax
  802d48:	5d                   	pop    %ebp
  802d49:	c3                   	ret    

00802d4a <devcons_stat>:

static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
  802d4a:	55                   	push   %ebp
  802d4b:	89 e5                	mov    %esp,%ebp
  802d4d:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<cons>");
  802d50:	c7 44 24 04 65 3d 80 	movl   $0x803d65,0x4(%esp)
  802d57:	00 
  802d58:	8b 45 0c             	mov    0xc(%ebp),%eax
  802d5b:	89 04 24             	mov    %eax,(%esp)
  802d5e:	e8 a7 e0 ff ff       	call   800e0a <strcpy>
	return 0;
}
  802d63:	b8 00 00 00 00       	mov    $0x0,%eax
  802d68:	c9                   	leave  
  802d69:	c3                   	ret    

00802d6a <devcons_write>:
	return 1;
}

static ssize_t
devcons_write(struct Fd *fd, const void *vbuf, size_t n)
{
  802d6a:	55                   	push   %ebp
  802d6b:	89 e5                	mov    %esp,%ebp
  802d6d:	57                   	push   %edi
  802d6e:	56                   	push   %esi
  802d6f:	53                   	push   %ebx
  802d70:	81 ec 9c 00 00 00    	sub    $0x9c,%esp
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  802d76:	b8 00 00 00 00       	mov    $0x0,%eax
  802d7b:	be 00 00 00 00       	mov    $0x0,%esi
  802d80:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802d84:	74 41                	je     802dc7 <devcons_write+0x5d>
		m = n - tot;
		if (m > sizeof(buf) - 1)
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  802d86:	8d bd 68 ff ff ff    	lea    -0x98(%ebp),%edi
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
		m = n - tot;
  802d8c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  802d8f:	29 c3                	sub    %eax,%ebx
		if (m > sizeof(buf) - 1)
  802d91:	81 fb 80 00 00 00    	cmp    $0x80,%ebx
  802d97:	ba 7f 00 00 00       	mov    $0x7f,%edx
  802d9c:	0f 43 da             	cmovae %edx,%ebx
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  802d9f:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802da3:	03 45 0c             	add    0xc(%ebp),%eax
  802da6:	89 44 24 04          	mov    %eax,0x4(%esp)
  802daa:	89 3c 24             	mov    %edi,(%esp)
  802dad:	e8 13 e2 ff ff       	call   800fc5 <memmove>
		sys_cputs(buf, m);
  802db2:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802db6:	89 3c 24             	mov    %edi,(%esp)
  802db9:	e8 42 e4 ff ff       	call   801200 <sys_cputs>
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  802dbe:	01 de                	add    %ebx,%esi
  802dc0:	89 f0                	mov    %esi,%eax
  802dc2:	3b 75 10             	cmp    0x10(%ebp),%esi
  802dc5:	72 c5                	jb     802d8c <devcons_write+0x22>
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
		sys_cputs(buf, m);
	}
	return tot;
}
  802dc7:	89 f0                	mov    %esi,%eax
  802dc9:	81 c4 9c 00 00 00    	add    $0x9c,%esp
  802dcf:	5b                   	pop    %ebx
  802dd0:	5e                   	pop    %esi
  802dd1:	5f                   	pop    %edi
  802dd2:	5d                   	pop    %ebp
  802dd3:	c3                   	ret    

00802dd4 <cputchar>:
#include <inc/string.h>
#include <inc/lib.h>

void
cputchar(int ch)
{
  802dd4:	55                   	push   %ebp
  802dd5:	89 e5                	mov    %esp,%ebp
  802dd7:	83 ec 28             	sub    $0x28,%esp
	char c = ch;
  802dda:	8b 45 08             	mov    0x8(%ebp),%eax
  802ddd:	88 45 f7             	mov    %al,-0x9(%ebp)

	// Unlike standard Unix's putchar,
	// the cputchar function _always_ outputs to the system console.
	sys_cputs(&c, 1);
  802de0:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  802de7:	00 
  802de8:	8d 45 f7             	lea    -0x9(%ebp),%eax
  802deb:	89 04 24             	mov    %eax,(%esp)
  802dee:	e8 0d e4 ff ff       	call   801200 <sys_cputs>
}
  802df3:	c9                   	leave  
  802df4:	c3                   	ret    

00802df5 <devcons_read>:
	return fd2num(fd);
}

static ssize_t
devcons_read(struct Fd *fd, void *vbuf, size_t n)
{
  802df5:	55                   	push   %ebp
  802df6:	89 e5                	mov    %esp,%ebp
  802df8:	83 ec 08             	sub    $0x8,%esp
	int c;

	if (n == 0)
  802dfb:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802dff:	75 07                	jne    802e08 <devcons_read+0x13>
  802e01:	eb 2d                	jmp    802e30 <devcons_read+0x3b>
		return 0;
	while ((c = sys_cgetc()) == 0)
		sys_yield();
  802e03:	e8 bd e7 ff ff       	call   8015c5 <sys_yield>
{
	int c;

	if (n == 0)
		return 0;
	while ((c = sys_cgetc()) == 0)
  802e08:	90                   	nop
  802e09:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  802e10:	e8 b7 e3 ff ff       	call   8011cc <sys_cgetc>
  802e15:	85 c0                	test   %eax,%eax
  802e17:	74 ea                	je     802e03 <devcons_read+0xe>
  802e19:	89 c2                	mov    %eax,%edx
		sys_yield();
	if (c < 0)
  802e1b:	85 c0                	test   %eax,%eax
  802e1d:	78 16                	js     802e35 <devcons_read+0x40>
		return c;
	if (c == 0x04)	// ctl-d is eof
  802e1f:	83 f8 04             	cmp    $0x4,%eax
  802e22:	74 0c                	je     802e30 <devcons_read+0x3b>
		return 0;
	*(char*)vbuf = c;
  802e24:	8b 45 0c             	mov    0xc(%ebp),%eax
  802e27:	88 10                	mov    %dl,(%eax)
  802e29:	b8 01 00 00 00       	mov    $0x1,%eax
	return 1;
  802e2e:	eb 05                	jmp    802e35 <devcons_read+0x40>
  802e30:	b8 00 00 00 00       	mov    $0x0,%eax
}
  802e35:	c9                   	leave  
  802e36:	c3                   	ret    

00802e37 <opencons>:
	return fd->fd_dev_id == devcons.dev_id;
}

int
opencons(void)
{
  802e37:	55                   	push   %ebp
  802e38:	89 e5                	mov    %esp,%ebp
  802e3a:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd* fd;

	if ((r = fd_alloc(&fd)) < 0)
  802e3d:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802e40:	89 04 24             	mov    %eax,(%esp)
  802e43:	e8 43 ed ff ff       	call   801b8b <fd_alloc>
  802e48:	85 c0                	test   %eax,%eax
  802e4a:	78 3f                	js     802e8b <opencons+0x54>
		return r;
	if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
  802e4c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802e53:	00 
  802e54:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802e57:	89 44 24 04          	mov    %eax,0x4(%esp)
  802e5b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802e62:	e8 ff e6 ff ff       	call   801566 <sys_page_alloc>
  802e67:	85 c0                	test   %eax,%eax
  802e69:	78 20                	js     802e8b <opencons+0x54>
		return r;
	fd->fd_dev_id = devcons.dev_id;
  802e6b:	8b 15 58 70 80 00    	mov    0x807058,%edx
  802e71:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802e74:	89 10                	mov    %edx,(%eax)
	fd->fd_omode = O_RDWR;
  802e76:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802e79:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	return fd2num(fd);
  802e80:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802e83:	89 04 24             	mov    %eax,(%esp)
  802e86:	e8 d5 ec ff ff       	call   801b60 <fd2num>
}
  802e8b:	c9                   	leave  
  802e8c:	c3                   	ret    

00802e8d <iscons>:
	.dev_stat =	devcons_stat
};

int
iscons(int fdnum)
{
  802e8d:	55                   	push   %ebp
  802e8e:	89 e5                	mov    %esp,%ebp
  802e90:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  802e93:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802e96:	89 44 24 04          	mov    %eax,0x4(%esp)
  802e9a:	8b 45 08             	mov    0x8(%ebp),%eax
  802e9d:	89 04 24             	mov    %eax,(%esp)
  802ea0:	e8 58 ed ff ff       	call   801bfd <fd_lookup>
  802ea5:	85 c0                	test   %eax,%eax
  802ea7:	78 11                	js     802eba <iscons+0x2d>
		return r;
	return fd->fd_dev_id == devcons.dev_id;
  802ea9:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802eac:	8b 00                	mov    (%eax),%eax
  802eae:	3b 05 58 70 80 00    	cmp    0x807058,%eax
  802eb4:	0f 94 c0             	sete   %al
  802eb7:	0f b6 c0             	movzbl %al,%eax
}
  802eba:	c9                   	leave  
  802ebb:	c3                   	ret    

00802ebc <getchar>:
	sys_cputs(&c, 1);
}

int
getchar(void)
{
  802ebc:	55                   	push   %ebp
  802ebd:	89 e5                	mov    %esp,%ebp
  802ebf:	83 ec 28             	sub    $0x28,%esp
	int r;

	// JOS does, however, support standard _input_ redirection,
	// allowing the user to redirect script files to the shell and such.
	// getchar() reads a character from file descriptor 0.
	r = read(0, &c, 1);
  802ec2:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  802ec9:	00 
  802eca:	8d 45 f7             	lea    -0x9(%ebp),%eax
  802ecd:	89 44 24 04          	mov    %eax,0x4(%esp)
  802ed1:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802ed8:	e8 86 ef ff ff       	call   801e63 <read>
	if (r < 0)
  802edd:	85 c0                	test   %eax,%eax
  802edf:	78 0f                	js     802ef0 <getchar+0x34>
		return r;
	if (r < 1)
  802ee1:	85 c0                	test   %eax,%eax
  802ee3:	7f 07                	jg     802eec <getchar+0x30>
  802ee5:	b8 f8 ff ff ff       	mov    $0xfffffff8,%eax
  802eea:	eb 04                	jmp    802ef0 <getchar+0x34>
		return -E_EOF;
	return c;
  802eec:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
}
  802ef0:	c9                   	leave  
  802ef1:	c3                   	ret    
	...

00802ef4 <set_pgfault_handler>:
// at UXSTACKTOP), and tell the kernel to call the assembly-language
// _pgfault_upcall routine when a page fault occurs.
//
void
set_pgfault_handler(void (*handler)(struct UTrapframe *utf))
{
  802ef4:	55                   	push   %ebp
  802ef5:	89 e5                	mov    %esp,%ebp
  802ef7:	83 ec 18             	sub    $0x18,%esp
	int r;

	if (_pgfault_handler == NULL) {
  802efa:	83 3d 94 70 80 00 00 	cmpl   $0x0,0x807094
  802f01:	75 55                	jne    802f58 <set_pgfault_handler+0x64>
		// First time through!
		// LAB 4: Your code here.
        if (sys_page_alloc(sys_getenvid(), (void *)(UXSTACKTOP-PGSIZE), PTE_P|PTE_U|PTE_W))
  802f03:	e8 f1 e6 ff ff       	call   8015f9 <sys_getenvid>
  802f08:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  802f0f:	00 
  802f10:	c7 44 24 04 00 f0 bf 	movl   $0xeebff000,0x4(%esp)
  802f17:	ee 
  802f18:	89 04 24             	mov    %eax,(%esp)
  802f1b:	e8 46 e6 ff ff       	call   801566 <sys_page_alloc>
  802f20:	85 c0                	test   %eax,%eax
  802f22:	74 1c                	je     802f40 <set_pgfault_handler+0x4c>
		    panic("set_pgfault_handler not implemented");
  802f24:	c7 44 24 08 74 3d 80 	movl   $0x803d74,0x8(%esp)
  802f2b:	00 
  802f2c:	c7 44 24 04 21 00 00 	movl   $0x21,0x4(%esp)
  802f33:	00 
  802f34:	c7 04 24 98 3d 80 00 	movl   $0x803d98,(%esp)
  802f3b:	e8 3c d7 ff ff       	call   80067c <_panic>
        sys_env_set_pgfault_upcall(env->env_id, _pgfault_upcall);
  802f40:	a1 8c 70 80 00       	mov    0x80708c,%eax
  802f45:	8b 40 4c             	mov    0x4c(%eax),%eax
  802f48:	c7 44 24 04 64 2f 80 	movl   $0x802f64,0x4(%esp)
  802f4f:	00 
  802f50:	89 04 24             	mov    %eax,(%esp)
  802f53:	e8 38 e4 ff ff       	call   801390 <sys_env_set_pgfault_upcall>
	}

	// Save handler pointer for assembly to call.
	_pgfault_handler = handler;
  802f58:	8b 45 08             	mov    0x8(%ebp),%eax
  802f5b:	a3 94 70 80 00       	mov    %eax,0x807094
}
  802f60:	c9                   	leave  
  802f61:	c3                   	ret    
	...

00802f64 <_pgfault_upcall>:

.text
.globl _pgfault_upcall
_pgfault_upcall:
	// Call the C page fault handler.
	pushl %esp			// function argument: pointer to UTF
  802f64:	54                   	push   %esp
	movl _pgfault_handler, %eax
  802f65:	a1 94 70 80 00       	mov    0x807094,%eax
	call *%eax
  802f6a:	ff d0                	call   *%eax
	addl $4, %esp			// pop function argument
  802f6c:	83 c4 04             	add    $0x4,%esp
	// may find that you have to rearrange your code in non-obvious
	// ways as registers become unavailable as scratch space.
	//
	// LAB 4: Your code here.

    subl $4, 48(%esp)
  802f6f:	83 6c 24 30 04       	subl   $0x4,0x30(%esp)
    movl 48(%esp), %eax
  802f74:	8b 44 24 30          	mov    0x30(%esp),%eax
    movl 40(%esp), %ebx
  802f78:	8b 5c 24 28          	mov    0x28(%esp),%ebx
    movl %ebx, (%eax)
  802f7c:	89 18                	mov    %ebx,(%eax)
    
	// Restore the trap-time registers.  After you do this, you
	// can no longer modify any general-purpose registers.
	// LAB 4: Your code here.
    addl $8, %esp
  802f7e:	83 c4 08             	add    $0x8,%esp
    popal
  802f81:	61                   	popa   
   
	// Restore eflags from the stack.  After you do this, you can
	// no longer use arithmetic operations or anything else that
	// modifies eflags.
	// LAB 4: Your code here.
    pushl 4(%esp)
  802f82:	ff 74 24 04          	pushl  0x4(%esp)
    popf
  802f86:	9d                   	popf   

	// Switch back to the adjusted trap-time stack.
	// LAB 4: Your code here.
    movl 8(%esp), %esp
  802f87:	8b 64 24 08          	mov    0x8(%esp),%esp

	// Return to re-execute the instruction that faulted.
	// LAB 4: Your code here.
    ret
  802f8b:	c3                   	ret    

00802f8c <pageref>:
#include <inc/lib.h>

int
pageref(void *v)
{
  802f8c:	55                   	push   %ebp
  802f8d:	89 e5                	mov    %esp,%ebp
	pte_t pte;

	if (!(vpd[PDX(v)] & PTE_P))
  802f8f:	8b 45 08             	mov    0x8(%ebp),%eax
  802f92:	89 c2                	mov    %eax,%edx
  802f94:	c1 ea 16             	shr    $0x16,%edx
  802f97:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  802f9e:	f6 c2 01             	test   $0x1,%dl
  802fa1:	74 26                	je     802fc9 <pageref+0x3d>
		return 0;
	pte = vpt[VPN(v)];
  802fa3:	c1 e8 0c             	shr    $0xc,%eax
  802fa6:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
	if (!(pte & PTE_P))
  802fad:	a8 01                	test   $0x1,%al
  802faf:	74 18                	je     802fc9 <pageref+0x3d>
		return 0;
	return pages[PPN(pte)].pp_ref;
  802fb1:	c1 e8 0c             	shr    $0xc,%eax
  802fb4:	8d 14 40             	lea    (%eax,%eax,2),%edx
  802fb7:	c1 e2 02             	shl    $0x2,%edx
  802fba:	b8 00 00 00 ef       	mov    $0xef000000,%eax
  802fbf:	0f b7 44 02 08       	movzwl 0x8(%edx,%eax,1),%eax
  802fc4:	0f b7 c0             	movzwl %ax,%eax
  802fc7:	eb 05                	jmp    802fce <pageref+0x42>
  802fc9:	b8 00 00 00 00       	mov    $0x0,%eax
}
  802fce:	5d                   	pop    %ebp
  802fcf:	c3                   	ret    

00802fd0 <inet_ntoa>:
 * @return pointer to a global static (!) buffer that holds the ASCII
 *         represenation of addr
 */
char *
inet_ntoa(struct in_addr addr)
{
  802fd0:	55                   	push   %ebp
  802fd1:	89 e5                	mov    %esp,%ebp
  802fd3:	57                   	push   %edi
  802fd4:	56                   	push   %esi
  802fd5:	53                   	push   %ebx
  802fd6:	83 ec 20             	sub    $0x20,%esp
  static char str[16];
  u32_t s_addr = addr.s_addr;
  802fd9:	8b 45 08             	mov    0x8(%ebp),%eax
  802fdc:	89 45 f0             	mov    %eax,-0x10(%ebp)
  u8_t rem;
  u8_t n;
  u8_t i;

  rp = str;
  ap = (u8_t *)&s_addr;
  802fdf:	8d 45 f0             	lea    -0x10(%ebp),%eax
  802fe2:	89 45 e0             	mov    %eax,-0x20(%ebp)
 * @param addr ip address in network order to convert
 * @return pointer to a global static (!) buffer that holds the ASCII
 *         represenation of addr
 */
char *
inet_ntoa(struct in_addr addr)
  802fe5:	8d 55 f3             	lea    -0xd(%ebp),%edx
  802fe8:	89 55 d8             	mov    %edx,-0x28(%ebp)
  802feb:	bb 7c 70 80 00       	mov    $0x80707c,%ebx
  rp = str;
  ap = (u8_t *)&s_addr;
  for(n = 0; n < 4; n++) {
    i = 0;
    do {
      rem = *ap % (u8_t)10;
  802ff0:	b9 cd ff ff ff       	mov    $0xffffffcd,%ecx
 * @param addr ip address in network order to convert
 * @return pointer to a global static (!) buffer that holds the ASCII
 *         represenation of addr
 */
char *
inet_ntoa(struct in_addr addr)
  802ff5:	8b 7d e0             	mov    -0x20(%ebp),%edi
  802ff8:	0f b6 37             	movzbl (%edi),%esi
  802ffb:	ba 00 00 00 00       	mov    $0x0,%edx
  803000:	89 d0                	mov    %edx,%eax
  803002:	89 f2                	mov    %esi,%edx
  803004:	89 de                	mov    %ebx,%esi
  803006:	89 c3                	mov    %eax,%ebx
  rp = str;
  ap = (u8_t *)&s_addr;
  for(n = 0; n < 4; n++) {
    i = 0;
    do {
      rem = *ap % (u8_t)10;
  803008:	89 d0                	mov    %edx,%eax
  80300a:	f6 e1                	mul    %cl
  80300c:	66 c1 e8 08          	shr    $0x8,%ax
  803010:	c0 e8 03             	shr    $0x3,%al
  803013:	89 c7                	mov    %eax,%edi
  803015:	8d 04 80             	lea    (%eax,%eax,4),%eax
  803018:	01 c0                	add    %eax,%eax
  80301a:	28 c2                	sub    %al,%dl
  80301c:	89 d0                	mov    %edx,%eax
      *ap /= (u8_t)10;
  80301e:	89 fa                	mov    %edi,%edx
      inv[i++] = '0' + rem;
  803020:	0f b6 fb             	movzbl %bl,%edi
  803023:	83 c0 30             	add    $0x30,%eax
  803026:	88 44 3d ed          	mov    %al,-0x13(%ebp,%edi,1)
  80302a:	8d 43 01             	lea    0x1(%ebx),%eax
    } while(*ap);
  80302d:	84 d2                	test   %dl,%dl
  80302f:	74 04                	je     803035 <inet_ntoa+0x65>
  803031:	89 c3                	mov    %eax,%ebx
  803033:	eb d3                	jmp    803008 <inet_ntoa+0x38>
  803035:	88 45 d7             	mov    %al,-0x29(%ebp)
  803038:	89 df                	mov    %ebx,%edi
  80303a:	89 f3                	mov    %esi,%ebx
  80303c:	89 d6                	mov    %edx,%esi
  80303e:	89 fa                	mov    %edi,%edx
  803040:	88 55 dc             	mov    %dl,-0x24(%ebp)
  803043:	89 f0                	mov    %esi,%eax
  803045:	8b 7d e0             	mov    -0x20(%ebp),%edi
  803048:	88 07                	mov    %al,(%edi)
    while(i--)
  80304a:	80 7d d7 00          	cmpb   $0x0,-0x29(%ebp)
  80304e:	74 2a                	je     80307a <inet_ntoa+0xaa>
 * @param addr ip address in network order to convert
 * @return pointer to a global static (!) buffer that holds the ASCII
 *         represenation of addr
 */
char *
inet_ntoa(struct in_addr addr)
  803050:	0f b6 45 dc          	movzbl -0x24(%ebp),%eax
  803054:	89 45 dc             	mov    %eax,-0x24(%ebp)
  803057:	8d 7c 03 01          	lea    0x1(%ebx,%eax,1),%edi
  80305b:	89 d8                	mov    %ebx,%eax
  80305d:	89 de                	mov    %ebx,%esi
      rem = *ap % (u8_t)10;
      *ap /= (u8_t)10;
      inv[i++] = '0' + rem;
    } while(*ap);
    while(i--)
      *rp++ = inv[i];
  80305f:	0f b6 da             	movzbl %dl,%ebx
  803062:	0f b6 5c 1d ed       	movzbl -0x13(%ebp,%ebx,1),%ebx
  803067:	88 18                	mov    %bl,(%eax)
  803069:	83 c0 01             	add    $0x1,%eax
    do {
      rem = *ap % (u8_t)10;
      *ap /= (u8_t)10;
      inv[i++] = '0' + rem;
    } while(*ap);
    while(i--)
  80306c:	83 ea 01             	sub    $0x1,%edx
  80306f:	39 f8                	cmp    %edi,%eax
  803071:	75 ec                	jne    80305f <inet_ntoa+0x8f>
  803073:	8b 55 dc             	mov    -0x24(%ebp),%edx
  803076:	8d 5c 16 01          	lea    0x1(%esi,%edx,1),%ebx
      *rp++ = inv[i];
    *rp++ = '.';
  80307a:	c6 03 2e             	movb   $0x2e,(%ebx)
  80307d:	8d 43 01             	lea    0x1(%ebx),%eax
  u8_t n;
  u8_t i;

  rp = str;
  ap = (u8_t *)&s_addr;
  for(n = 0; n < 4; n++) {
  803080:	8b 7d d8             	mov    -0x28(%ebp),%edi
  803083:	39 7d e0             	cmp    %edi,-0x20(%ebp)
  803086:	74 0b                	je     803093 <inet_ntoa+0xc3>
      inv[i++] = '0' + rem;
    } while(*ap);
    while(i--)
      *rp++ = inv[i];
    *rp++ = '.';
    ap++;
  803088:	83 45 e0 01          	addl   $0x1,-0x20(%ebp)
  80308c:	89 c3                	mov    %eax,%ebx
  80308e:	e9 62 ff ff ff       	jmp    802ff5 <inet_ntoa+0x25>
  }
  *--rp = 0;
  803093:	c6 03 00             	movb   $0x0,(%ebx)
  return str;
}
  803096:	b8 7c 70 80 00       	mov    $0x80707c,%eax
  80309b:	83 c4 20             	add    $0x20,%esp
  80309e:	5b                   	pop    %ebx
  80309f:	5e                   	pop    %esi
  8030a0:	5f                   	pop    %edi
  8030a1:	5d                   	pop    %ebp
  8030a2:	c3                   	ret    

008030a3 <htons>:
 * @param n u16_t in host byte order
 * @return n in network byte order
 */
u16_t
htons(u16_t n)
{
  8030a3:	55                   	push   %ebp
  8030a4:	89 e5                	mov    %esp,%ebp
  8030a6:	0f b7 45 08          	movzwl 0x8(%ebp),%eax
  8030aa:	66 c1 c0 08          	rol    $0x8,%ax
  return ((n & 0xff) << 8) | ((n & 0xff00) >> 8);
}
  8030ae:	5d                   	pop    %ebp
  8030af:	c3                   	ret    

008030b0 <ntohs>:
 * @param n u16_t in network byte order
 * @return n in host byte order
 */
u16_t
ntohs(u16_t n)
{
  8030b0:	55                   	push   %ebp
  8030b1:	89 e5                	mov    %esp,%ebp
  8030b3:	83 ec 04             	sub    $0x4,%esp
  return htons(n);
  8030b6:	0f b7 45 08          	movzwl 0x8(%ebp),%eax
  8030ba:	89 04 24             	mov    %eax,(%esp)
  8030bd:	e8 e1 ff ff ff       	call   8030a3 <htons>
}
  8030c2:	c9                   	leave  
  8030c3:	c3                   	ret    

008030c4 <htonl>:
 * @param n u32_t in host byte order
 * @return n in network byte order
 */
u32_t
htonl(u32_t n)
{
  8030c4:	55                   	push   %ebp
  8030c5:	89 e5                	mov    %esp,%ebp
  8030c7:	8b 55 08             	mov    0x8(%ebp),%edx
  8030ca:	89 d1                	mov    %edx,%ecx
  8030cc:	c1 e9 18             	shr    $0x18,%ecx
  8030cf:	89 d0                	mov    %edx,%eax
  8030d1:	c1 e0 18             	shl    $0x18,%eax
  8030d4:	09 c8                	or     %ecx,%eax
  8030d6:	89 d1                	mov    %edx,%ecx
  8030d8:	81 e1 00 ff 00 00    	and    $0xff00,%ecx
  8030de:	c1 e1 08             	shl    $0x8,%ecx
  8030e1:	09 c8                	or     %ecx,%eax
  8030e3:	81 e2 00 00 ff 00    	and    $0xff0000,%edx
  8030e9:	c1 ea 08             	shr    $0x8,%edx
  8030ec:	09 d0                	or     %edx,%eax
  return ((n & 0xff) << 24) |
    ((n & 0xff00) << 8) |
    ((n & 0xff0000UL) >> 8) |
    ((n & 0xff000000UL) >> 24);
}
  8030ee:	5d                   	pop    %ebp
  8030ef:	c3                   	ret    

008030f0 <inet_aton>:
 * @param addr pointer to which to save the ip address in network order
 * @return 1 if cp could be converted to addr, 0 on failure
 */
int
inet_aton(const char *cp, struct in_addr *addr)
{
  8030f0:	55                   	push   %ebp
  8030f1:	89 e5                	mov    %esp,%ebp
  8030f3:	57                   	push   %edi
  8030f4:	56                   	push   %esi
  8030f5:	53                   	push   %ebx
  8030f6:	83 ec 28             	sub    $0x28,%esp
  8030f9:	8b 45 08             	mov    0x8(%ebp),%eax
  u32_t val;
  int base, n, c;
  u32_t parts[4];
  u32_t *pp = parts;

  c = *cp;
  8030fc:	0f be 10             	movsbl (%eax),%edx
    /*
     * Collect number up to ``.''.
     * Values are specified as for C:
     * 0x=hex, 0=octal, 1-9=decimal.
     */
    if (!isdigit(c))
  8030ff:	8d 4a d0             	lea    -0x30(%edx),%ecx
  803102:	80 f9 09             	cmp    $0x9,%cl
  803105:	0f 87 a8 01 00 00    	ja     8032b3 <inet_aton+0x1c3>
  80310b:	8d 4d e4             	lea    -0x1c(%ebp),%ecx
  80310e:	89 4d d8             	mov    %ecx,-0x28(%ebp)
       * Internet format:
       *  a.b.c.d
       *  a.b.c   (with c treated as 16 bits)
       *  a.b (with b treated as 24 bits)
       */
      if (pp >= parts + 3)
  803111:	8d 5d f0             	lea    -0x10(%ebp),%ebx
  803114:	89 5d d4             	mov    %ebx,-0x2c(%ebp)
     */
    if (!isdigit(c))
      return (0);
    val = 0;
    base = 10;
    if (c == '0') {
  803117:	c7 45 e0 0a 00 00 00 	movl   $0xa,-0x20(%ebp)
  80311e:	83 fa 30             	cmp    $0x30,%edx
  803121:	75 24                	jne    803147 <inet_aton+0x57>
      c = *++cp;
  803123:	83 c0 01             	add    $0x1,%eax
  803126:	0f be 10             	movsbl (%eax),%edx
      if (c == 'x' || c == 'X') {
  803129:	83 fa 78             	cmp    $0x78,%edx
  80312c:	74 0c                	je     80313a <inet_aton+0x4a>
  80312e:	c7 45 e0 08 00 00 00 	movl   $0x8,-0x20(%ebp)
  803135:	83 fa 58             	cmp    $0x58,%edx
  803138:	75 0d                	jne    803147 <inet_aton+0x57>
        base = 16;
        c = *++cp;
  80313a:	83 c0 01             	add    $0x1,%eax
  80313d:	0f be 10             	movsbl (%eax),%edx
  803140:	c7 45 e0 10 00 00 00 	movl   $0x10,-0x20(%ebp)
  803147:	83 c0 01             	add    $0x1,%eax
  80314a:	be 00 00 00 00       	mov    $0x0,%esi
  80314f:	eb 03                	jmp    803154 <inet_aton+0x64>
  803151:	83 c0 01             	add    $0x1,%eax
  803154:	8d 78 ff             	lea    -0x1(%eax),%edi
      } else
        base = 8;
    }
    for (;;) {
      if (isdigit(c)) {
  803157:	89 d1                	mov    %edx,%ecx
  803159:	8d 59 d0             	lea    -0x30(%ecx),%ebx
  80315c:	80 fb 09             	cmp    $0x9,%bl
  80315f:	77 0d                	ja     80316e <inet_aton+0x7e>
        val = (val * base) + (int)(c - '0');
  803161:	0f af 75 e0          	imul   -0x20(%ebp),%esi
  803165:	8d 74 32 d0          	lea    -0x30(%edx,%esi,1),%esi
        c = *++cp;
  803169:	0f be 10             	movsbl (%eax),%edx
  80316c:	eb e3                	jmp    803151 <inet_aton+0x61>
      } else if (base == 16 && isxdigit(c)) {
  80316e:	83 7d e0 10          	cmpl   $0x10,-0x20(%ebp)
  803172:	75 2b                	jne    80319f <inet_aton+0xaf>
  803174:	8d 59 9f             	lea    -0x61(%ecx),%ebx
  803177:	88 5d d3             	mov    %bl,-0x2d(%ebp)
  80317a:	80 fb 05             	cmp    $0x5,%bl
  80317d:	76 08                	jbe    803187 <inet_aton+0x97>
  80317f:	8d 59 bf             	lea    -0x41(%ecx),%ebx
  803182:	80 fb 05             	cmp    $0x5,%bl
  803185:	77 18                	ja     80319f <inet_aton+0xaf>
        val = (val << 4) | (int)(c + 10 - (islower(c) ? 'a' : 'A'));
  803187:	80 7d d3 1a          	cmpb   $0x1a,-0x2d(%ebp)
  80318b:	19 c9                	sbb    %ecx,%ecx
  80318d:	83 e1 20             	and    $0x20,%ecx
  803190:	c1 e6 04             	shl    $0x4,%esi
  803193:	29 ca                	sub    %ecx,%edx
  803195:	8d 52 c9             	lea    -0x37(%edx),%edx
  803198:	09 d6                	or     %edx,%esi
        c = *++cp;
  80319a:	0f be 10             	movsbl (%eax),%edx
  80319d:	eb b2                	jmp    803151 <inet_aton+0x61>
      } else
        break;
    }
    if (c == '.') {
  80319f:	83 fa 2e             	cmp    $0x2e,%edx
  8031a2:	75 29                	jne    8031cd <inet_aton+0xdd>
       * Internet format:
       *  a.b.c.d
       *  a.b.c   (with c treated as 16 bits)
       *  a.b (with b treated as 24 bits)
       */
      if (pp >= parts + 3)
  8031a4:	8b 55 d8             	mov    -0x28(%ebp),%edx
  8031a7:	39 55 d4             	cmp    %edx,-0x2c(%ebp)
  8031aa:	0f 86 03 01 00 00    	jbe    8032b3 <inet_aton+0x1c3>
        return (0);
      *pp++ = val;
  8031b0:	89 32                	mov    %esi,(%edx)
      c = *++cp;
  8031b2:	8d 47 01             	lea    0x1(%edi),%eax
  8031b5:	0f be 10             	movsbl (%eax),%edx
    /*
     * Collect number up to ``.''.
     * Values are specified as for C:
     * 0x=hex, 0=octal, 1-9=decimal.
     */
    if (!isdigit(c))
  8031b8:	8d 4a d0             	lea    -0x30(%edx),%ecx
  8031bb:	80 f9 09             	cmp    $0x9,%cl
  8031be:	0f 87 ef 00 00 00    	ja     8032b3 <inet_aton+0x1c3>
       *  a.b.c   (with c treated as 16 bits)
       *  a.b (with b treated as 24 bits)
       */
      if (pp >= parts + 3)
        return (0);
      *pp++ = val;
  8031c4:	83 45 d8 04          	addl   $0x4,-0x28(%ebp)
  8031c8:	e9 4a ff ff ff       	jmp    803117 <inet_aton+0x27>
  8031cd:	89 f3                	mov    %esi,%ebx
  8031cf:	89 f0                	mov    %esi,%eax
      break;
  }
  /*
   * Check for trailing characters.
   */
  if (c != '\0' && (!isprint(c) || !isspace(c)))
  8031d1:	85 d2                	test   %edx,%edx
  8031d3:	74 36                	je     80320b <inet_aton+0x11b>
  8031d5:	80 f9 1f             	cmp    $0x1f,%cl
  8031d8:	0f 86 d5 00 00 00    	jbe    8032b3 <inet_aton+0x1c3>
  8031de:	84 d2                	test   %dl,%dl
  8031e0:	0f 88 cd 00 00 00    	js     8032b3 <inet_aton+0x1c3>
  8031e6:	83 fa 20             	cmp    $0x20,%edx
  8031e9:	74 20                	je     80320b <inet_aton+0x11b>
  8031eb:	83 fa 0c             	cmp    $0xc,%edx
  8031ee:	66 90                	xchg   %ax,%ax
  8031f0:	74 19                	je     80320b <inet_aton+0x11b>
  8031f2:	83 fa 0a             	cmp    $0xa,%edx
  8031f5:	74 14                	je     80320b <inet_aton+0x11b>
  8031f7:	83 fa 0d             	cmp    $0xd,%edx
  8031fa:	74 0f                	je     80320b <inet_aton+0x11b>
  8031fc:	83 fa 09             	cmp    $0x9,%edx
  8031ff:	90                   	nop
  803200:	74 09                	je     80320b <inet_aton+0x11b>
  803202:	83 fa 0b             	cmp    $0xb,%edx
  803205:	0f 85 a8 00 00 00    	jne    8032b3 <inet_aton+0x1c3>
  /*
   * Concoct the address according to
   * the number of parts specified.
   */
  n = pp - parts + 1;
  switch (n) {
  80320b:	8d 55 e4             	lea    -0x1c(%ebp),%edx
  80320e:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  803211:	29 d1                	sub    %edx,%ecx
  803213:	89 ca                	mov    %ecx,%edx
  803215:	c1 fa 02             	sar    $0x2,%edx
  803218:	83 c2 01             	add    $0x1,%edx
  80321b:	83 fa 02             	cmp    $0x2,%edx
  80321e:	74 2a                	je     80324a <inet_aton+0x15a>
  803220:	83 fa 02             	cmp    $0x2,%edx
  803223:	7f 0d                	jg     803232 <inet_aton+0x142>
  803225:	85 d2                	test   %edx,%edx
  803227:	0f 84 86 00 00 00    	je     8032b3 <inet_aton+0x1c3>
  80322d:	8d 76 00             	lea    0x0(%esi),%esi
  803230:	eb 62                	jmp    803294 <inet_aton+0x1a4>
  803232:	83 fa 03             	cmp    $0x3,%edx
  803235:	8d 76 00             	lea    0x0(%esi),%esi
  803238:	74 22                	je     80325c <inet_aton+0x16c>
  80323a:	83 fa 04             	cmp    $0x4,%edx
  80323d:	8d 76 00             	lea    0x0(%esi),%esi
  803240:	75 52                	jne    803294 <inet_aton+0x1a4>
  803242:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  803248:	eb 2b                	jmp    803275 <inet_aton+0x185>

  case 1:             /* a -- 32 bits */
    break;

  case 2:             /* a.b -- 8.24 bits */
    if (val > 0xffffffUL)
  80324a:	3d ff ff ff 00       	cmp    $0xffffff,%eax
  80324f:	90                   	nop
  803250:	77 61                	ja     8032b3 <inet_aton+0x1c3>
      return (0);
    val |= parts[0] << 24;
  803252:	8b 5d e4             	mov    -0x1c(%ebp),%ebx
  803255:	c1 e3 18             	shl    $0x18,%ebx
  803258:	09 c3                	or     %eax,%ebx
    break;
  80325a:	eb 38                	jmp    803294 <inet_aton+0x1a4>

  case 3:             /* a.b.c -- 8.8.16 bits */
    if (val > 0xffff)
  80325c:	3d ff ff 00 00       	cmp    $0xffff,%eax
  803261:	77 50                	ja     8032b3 <inet_aton+0x1c3>
      return (0);
    val |= (parts[0] << 24) | (parts[1] << 16);
  803263:	8b 5d e8             	mov    -0x18(%ebp),%ebx
  803266:	c1 e3 10             	shl    $0x10,%ebx
  803269:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  80326c:	c1 e2 18             	shl    $0x18,%edx
  80326f:	09 d3                	or     %edx,%ebx
  803271:	09 c3                	or     %eax,%ebx
    break;
  803273:	eb 1f                	jmp    803294 <inet_aton+0x1a4>

  case 4:             /* a.b.c.d -- 8.8.8.8 bits */
    if (val > 0xff)
  803275:	3d ff 00 00 00       	cmp    $0xff,%eax
  80327a:	77 37                	ja     8032b3 <inet_aton+0x1c3>
      return (0);
    val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
  80327c:	8b 5d e8             	mov    -0x18(%ebp),%ebx
  80327f:	c1 e3 10             	shl    $0x10,%ebx
  803282:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  803285:	c1 e2 18             	shl    $0x18,%edx
  803288:	09 d3                	or     %edx,%ebx
  80328a:	8b 55 ec             	mov    -0x14(%ebp),%edx
  80328d:	c1 e2 08             	shl    $0x8,%edx
  803290:	09 d3                	or     %edx,%ebx
  803292:	09 c3                	or     %eax,%ebx
    break;
  }
  if (addr)
  803294:	b8 01 00 00 00       	mov    $0x1,%eax
  803299:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  80329d:	74 19                	je     8032b8 <inet_aton+0x1c8>
    addr->s_addr = htonl(val);
  80329f:	89 1c 24             	mov    %ebx,(%esp)
  8032a2:	e8 1d fe ff ff       	call   8030c4 <htonl>
  8032a7:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  8032aa:	89 03                	mov    %eax,(%ebx)
  8032ac:	b8 01 00 00 00       	mov    $0x1,%eax
  8032b1:	eb 05                	jmp    8032b8 <inet_aton+0x1c8>
  8032b3:	b8 00 00 00 00       	mov    $0x0,%eax
  return (1);
}
  8032b8:	83 c4 28             	add    $0x28,%esp
  8032bb:	5b                   	pop    %ebx
  8032bc:	5e                   	pop    %esi
  8032bd:	5f                   	pop    %edi
  8032be:	5d                   	pop    %ebp
  8032bf:	c3                   	ret    

008032c0 <inet_addr>:
 * @param cp IP address in ascii represenation (e.g. "127.0.0.1")
 * @return ip address in network order
 */
u32_t
inet_addr(const char *cp)
{
  8032c0:	55                   	push   %ebp
  8032c1:	89 e5                	mov    %esp,%ebp
  8032c3:	83 ec 18             	sub    $0x18,%esp
  struct in_addr val;

  if (inet_aton(cp, &val)) {
  8032c6:	8d 45 fc             	lea    -0x4(%ebp),%eax
  8032c9:	89 44 24 04          	mov    %eax,0x4(%esp)
  8032cd:	8b 45 08             	mov    0x8(%ebp),%eax
  8032d0:	89 04 24             	mov    %eax,(%esp)
  8032d3:	e8 18 fe ff ff       	call   8030f0 <inet_aton>
  8032d8:	85 c0                	test   %eax,%eax
  8032da:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
  8032df:	0f 45 45 fc          	cmovne -0x4(%ebp),%eax
    return (val.s_addr);
  }
  return (INADDR_NONE);
}
  8032e3:	c9                   	leave  
  8032e4:	c3                   	ret    

008032e5 <ntohl>:
 * @param n u32_t in network byte order
 * @return n in host byte order
 */
u32_t
ntohl(u32_t n)
{
  8032e5:	55                   	push   %ebp
  8032e6:	89 e5                	mov    %esp,%ebp
  8032e8:	83 ec 04             	sub    $0x4,%esp
  return htonl(n);
  8032eb:	8b 45 08             	mov    0x8(%ebp),%eax
  8032ee:	89 04 24             	mov    %eax,(%esp)
  8032f1:	e8 ce fd ff ff       	call   8030c4 <htonl>
}
  8032f6:	c9                   	leave  
  8032f7:	c3                   	ret    
	...

00803300 <__udivdi3>:
  803300:	55                   	push   %ebp
  803301:	89 e5                	mov    %esp,%ebp
  803303:	57                   	push   %edi
  803304:	56                   	push   %esi
  803305:	83 ec 10             	sub    $0x10,%esp
  803308:	8b 45 14             	mov    0x14(%ebp),%eax
  80330b:	8b 55 08             	mov    0x8(%ebp),%edx
  80330e:	8b 75 10             	mov    0x10(%ebp),%esi
  803311:	8b 7d 0c             	mov    0xc(%ebp),%edi
  803314:	85 c0                	test   %eax,%eax
  803316:	89 55 f0             	mov    %edx,-0x10(%ebp)
  803319:	75 35                	jne    803350 <__udivdi3+0x50>
  80331b:	39 fe                	cmp    %edi,%esi
  80331d:	77 61                	ja     803380 <__udivdi3+0x80>
  80331f:	85 f6                	test   %esi,%esi
  803321:	75 0b                	jne    80332e <__udivdi3+0x2e>
  803323:	b8 01 00 00 00       	mov    $0x1,%eax
  803328:	31 d2                	xor    %edx,%edx
  80332a:	f7 f6                	div    %esi
  80332c:	89 c6                	mov    %eax,%esi
  80332e:	8b 4d f0             	mov    -0x10(%ebp),%ecx
  803331:	31 d2                	xor    %edx,%edx
  803333:	89 f8                	mov    %edi,%eax
  803335:	f7 f6                	div    %esi
  803337:	89 c7                	mov    %eax,%edi
  803339:	89 c8                	mov    %ecx,%eax
  80333b:	f7 f6                	div    %esi
  80333d:	89 c1                	mov    %eax,%ecx
  80333f:	89 fa                	mov    %edi,%edx
  803341:	89 c8                	mov    %ecx,%eax
  803343:	83 c4 10             	add    $0x10,%esp
  803346:	5e                   	pop    %esi
  803347:	5f                   	pop    %edi
  803348:	5d                   	pop    %ebp
  803349:	c3                   	ret    
  80334a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  803350:	39 f8                	cmp    %edi,%eax
  803352:	77 1c                	ja     803370 <__udivdi3+0x70>
  803354:	0f bd d0             	bsr    %eax,%edx
  803357:	83 f2 1f             	xor    $0x1f,%edx
  80335a:	89 55 f4             	mov    %edx,-0xc(%ebp)
  80335d:	75 39                	jne    803398 <__udivdi3+0x98>
  80335f:	3b 75 f0             	cmp    -0x10(%ebp),%esi
  803362:	0f 86 a0 00 00 00    	jbe    803408 <__udivdi3+0x108>
  803368:	39 f8                	cmp    %edi,%eax
  80336a:	0f 82 98 00 00 00    	jb     803408 <__udivdi3+0x108>
  803370:	31 ff                	xor    %edi,%edi
  803372:	31 c9                	xor    %ecx,%ecx
  803374:	89 c8                	mov    %ecx,%eax
  803376:	89 fa                	mov    %edi,%edx
  803378:	83 c4 10             	add    $0x10,%esp
  80337b:	5e                   	pop    %esi
  80337c:	5f                   	pop    %edi
  80337d:	5d                   	pop    %ebp
  80337e:	c3                   	ret    
  80337f:	90                   	nop
  803380:	89 d1                	mov    %edx,%ecx
  803382:	89 fa                	mov    %edi,%edx
  803384:	89 c8                	mov    %ecx,%eax
  803386:	31 ff                	xor    %edi,%edi
  803388:	f7 f6                	div    %esi
  80338a:	89 c1                	mov    %eax,%ecx
  80338c:	89 fa                	mov    %edi,%edx
  80338e:	89 c8                	mov    %ecx,%eax
  803390:	83 c4 10             	add    $0x10,%esp
  803393:	5e                   	pop    %esi
  803394:	5f                   	pop    %edi
  803395:	5d                   	pop    %ebp
  803396:	c3                   	ret    
  803397:	90                   	nop
  803398:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  80339c:	89 f2                	mov    %esi,%edx
  80339e:	d3 e0                	shl    %cl,%eax
  8033a0:	89 45 ec             	mov    %eax,-0x14(%ebp)
  8033a3:	b8 20 00 00 00       	mov    $0x20,%eax
  8033a8:	2b 45 f4             	sub    -0xc(%ebp),%eax
  8033ab:	89 c1                	mov    %eax,%ecx
  8033ad:	d3 ea                	shr    %cl,%edx
  8033af:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  8033b3:	0b 55 ec             	or     -0x14(%ebp),%edx
  8033b6:	d3 e6                	shl    %cl,%esi
  8033b8:	89 c1                	mov    %eax,%ecx
  8033ba:	89 75 e8             	mov    %esi,-0x18(%ebp)
  8033bd:	89 fe                	mov    %edi,%esi
  8033bf:	d3 ee                	shr    %cl,%esi
  8033c1:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  8033c5:	89 55 ec             	mov    %edx,-0x14(%ebp)
  8033c8:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8033cb:	d3 e7                	shl    %cl,%edi
  8033cd:	89 c1                	mov    %eax,%ecx
  8033cf:	d3 ea                	shr    %cl,%edx
  8033d1:	09 d7                	or     %edx,%edi
  8033d3:	89 f2                	mov    %esi,%edx
  8033d5:	89 f8                	mov    %edi,%eax
  8033d7:	f7 75 ec             	divl   -0x14(%ebp)
  8033da:	89 d6                	mov    %edx,%esi
  8033dc:	89 c7                	mov    %eax,%edi
  8033de:	f7 65 e8             	mull   -0x18(%ebp)
  8033e1:	39 d6                	cmp    %edx,%esi
  8033e3:	89 55 ec             	mov    %edx,-0x14(%ebp)
  8033e6:	72 30                	jb     803418 <__udivdi3+0x118>
  8033e8:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8033eb:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  8033ef:	d3 e2                	shl    %cl,%edx
  8033f1:	39 c2                	cmp    %eax,%edx
  8033f3:	73 05                	jae    8033fa <__udivdi3+0xfa>
  8033f5:	3b 75 ec             	cmp    -0x14(%ebp),%esi
  8033f8:	74 1e                	je     803418 <__udivdi3+0x118>
  8033fa:	89 f9                	mov    %edi,%ecx
  8033fc:	31 ff                	xor    %edi,%edi
  8033fe:	e9 71 ff ff ff       	jmp    803374 <__udivdi3+0x74>
  803403:	90                   	nop
  803404:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  803408:	31 ff                	xor    %edi,%edi
  80340a:	b9 01 00 00 00       	mov    $0x1,%ecx
  80340f:	e9 60 ff ff ff       	jmp    803374 <__udivdi3+0x74>
  803414:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  803418:	8d 4f ff             	lea    -0x1(%edi),%ecx
  80341b:	31 ff                	xor    %edi,%edi
  80341d:	89 c8                	mov    %ecx,%eax
  80341f:	89 fa                	mov    %edi,%edx
  803421:	83 c4 10             	add    $0x10,%esp
  803424:	5e                   	pop    %esi
  803425:	5f                   	pop    %edi
  803426:	5d                   	pop    %ebp
  803427:	c3                   	ret    
	...

00803430 <__umoddi3>:
  803430:	55                   	push   %ebp
  803431:	89 e5                	mov    %esp,%ebp
  803433:	57                   	push   %edi
  803434:	56                   	push   %esi
  803435:	83 ec 20             	sub    $0x20,%esp
  803438:	8b 55 14             	mov    0x14(%ebp),%edx
  80343b:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80343e:	8b 7d 10             	mov    0x10(%ebp),%edi
  803441:	8b 75 0c             	mov    0xc(%ebp),%esi
  803444:	85 d2                	test   %edx,%edx
  803446:	89 c8                	mov    %ecx,%eax
  803448:	89 4d f4             	mov    %ecx,-0xc(%ebp)
  80344b:	75 13                	jne    803460 <__umoddi3+0x30>
  80344d:	39 f7                	cmp    %esi,%edi
  80344f:	76 3f                	jbe    803490 <__umoddi3+0x60>
  803451:	89 f2                	mov    %esi,%edx
  803453:	f7 f7                	div    %edi
  803455:	89 d0                	mov    %edx,%eax
  803457:	31 d2                	xor    %edx,%edx
  803459:	83 c4 20             	add    $0x20,%esp
  80345c:	5e                   	pop    %esi
  80345d:	5f                   	pop    %edi
  80345e:	5d                   	pop    %ebp
  80345f:	c3                   	ret    
  803460:	39 f2                	cmp    %esi,%edx
  803462:	77 4c                	ja     8034b0 <__umoddi3+0x80>
  803464:	0f bd ca             	bsr    %edx,%ecx
  803467:	83 f1 1f             	xor    $0x1f,%ecx
  80346a:	89 4d f0             	mov    %ecx,-0x10(%ebp)
  80346d:	75 51                	jne    8034c0 <__umoddi3+0x90>
  80346f:	3b 7d f4             	cmp    -0xc(%ebp),%edi
  803472:	0f 87 e0 00 00 00    	ja     803558 <__umoddi3+0x128>
  803478:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80347b:	29 f8                	sub    %edi,%eax
  80347d:	19 d6                	sbb    %edx,%esi
  80347f:	89 45 f4             	mov    %eax,-0xc(%ebp)
  803482:	8b 45 f4             	mov    -0xc(%ebp),%eax
  803485:	89 f2                	mov    %esi,%edx
  803487:	83 c4 20             	add    $0x20,%esp
  80348a:	5e                   	pop    %esi
  80348b:	5f                   	pop    %edi
  80348c:	5d                   	pop    %ebp
  80348d:	c3                   	ret    
  80348e:	66 90                	xchg   %ax,%ax
  803490:	85 ff                	test   %edi,%edi
  803492:	75 0b                	jne    80349f <__umoddi3+0x6f>
  803494:	b8 01 00 00 00       	mov    $0x1,%eax
  803499:	31 d2                	xor    %edx,%edx
  80349b:	f7 f7                	div    %edi
  80349d:	89 c7                	mov    %eax,%edi
  80349f:	89 f0                	mov    %esi,%eax
  8034a1:	31 d2                	xor    %edx,%edx
  8034a3:	f7 f7                	div    %edi
  8034a5:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8034a8:	f7 f7                	div    %edi
  8034aa:	eb a9                	jmp    803455 <__umoddi3+0x25>
  8034ac:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8034b0:	89 c8                	mov    %ecx,%eax
  8034b2:	89 f2                	mov    %esi,%edx
  8034b4:	83 c4 20             	add    $0x20,%esp
  8034b7:	5e                   	pop    %esi
  8034b8:	5f                   	pop    %edi
  8034b9:	5d                   	pop    %ebp
  8034ba:	c3                   	ret    
  8034bb:	90                   	nop
  8034bc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8034c0:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  8034c4:	d3 e2                	shl    %cl,%edx
  8034c6:	89 55 f4             	mov    %edx,-0xc(%ebp)
  8034c9:	ba 20 00 00 00       	mov    $0x20,%edx
  8034ce:	2b 55 f0             	sub    -0x10(%ebp),%edx
  8034d1:	89 55 ec             	mov    %edx,-0x14(%ebp)
  8034d4:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  8034d8:	89 fa                	mov    %edi,%edx
  8034da:	d3 ea                	shr    %cl,%edx
  8034dc:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  8034e0:	0b 55 f4             	or     -0xc(%ebp),%edx
  8034e3:	d3 e7                	shl    %cl,%edi
  8034e5:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  8034e9:	89 55 f4             	mov    %edx,-0xc(%ebp)
  8034ec:	89 f2                	mov    %esi,%edx
  8034ee:	89 7d e8             	mov    %edi,-0x18(%ebp)
  8034f1:	89 c7                	mov    %eax,%edi
  8034f3:	d3 ea                	shr    %cl,%edx
  8034f5:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  8034f9:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8034fc:	89 c2                	mov    %eax,%edx
  8034fe:	d3 e6                	shl    %cl,%esi
  803500:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  803504:	d3 ea                	shr    %cl,%edx
  803506:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  80350a:	09 d6                	or     %edx,%esi
  80350c:	89 f0                	mov    %esi,%eax
  80350e:	8b 75 e4             	mov    -0x1c(%ebp),%esi
  803511:	d3 e7                	shl    %cl,%edi
  803513:	89 f2                	mov    %esi,%edx
  803515:	f7 75 f4             	divl   -0xc(%ebp)
  803518:	89 d6                	mov    %edx,%esi
  80351a:	f7 65 e8             	mull   -0x18(%ebp)
  80351d:	39 d6                	cmp    %edx,%esi
  80351f:	72 2b                	jb     80354c <__umoddi3+0x11c>
  803521:	39 c7                	cmp    %eax,%edi
  803523:	72 23                	jb     803548 <__umoddi3+0x118>
  803525:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  803529:	29 c7                	sub    %eax,%edi
  80352b:	19 d6                	sbb    %edx,%esi
  80352d:	89 f0                	mov    %esi,%eax
  80352f:	89 f2                	mov    %esi,%edx
  803531:	d3 ef                	shr    %cl,%edi
  803533:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  803537:	d3 e0                	shl    %cl,%eax
  803539:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  80353d:	09 f8                	or     %edi,%eax
  80353f:	d3 ea                	shr    %cl,%edx
  803541:	83 c4 20             	add    $0x20,%esp
  803544:	5e                   	pop    %esi
  803545:	5f                   	pop    %edi
  803546:	5d                   	pop    %ebp
  803547:	c3                   	ret    
  803548:	39 d6                	cmp    %edx,%esi
  80354a:	75 d9                	jne    803525 <__umoddi3+0xf5>
  80354c:	2b 45 e8             	sub    -0x18(%ebp),%eax
  80354f:	1b 55 f4             	sbb    -0xc(%ebp),%edx
  803552:	eb d1                	jmp    803525 <__umoddi3+0xf5>
  803554:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  803558:	39 f2                	cmp    %esi,%edx
  80355a:	0f 82 18 ff ff ff    	jb     803478 <__umoddi3+0x48>
  803560:	e9 1d ff ff ff       	jmp    803482 <__umoddi3+0x52>
